Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

красота и фиксы #87

Merged
merged 1 commit into from
Sep 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions .github/workflows/changelog.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,9 @@ on:
types: [closed]

env:
BOT_TOKEN: ${{ secrets.BOT_TOKEN }}
CHANGELOG_DIR: Resources/Changelog/ChangelogLPP.yml
GITHUB_TOKEN: ${{ secrets.BOT_TOKEN }}
CHANGELOG_DIR: ${{ vars.CHANGELOG_DIR }}
PR_NUMBER: ${{ github.event.number }}
CHANGELOG_DISCORD_WEBHOOK: ${{ secrets.CHANGELOG_DISCORD_WEBHOOK }}

jobs:
changelog:
Expand All @@ -21,7 +20,7 @@ jobs:
uses: actions/checkout@v3
with:
token: ${{ secrets.BOT_TOKEN }}
ref: master
ref: ${{ vars.CHANGELOG_BRANCH }}

- name: Setup Git
run: |
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Publish Changelog
name: Discord Changelog

on:
workflow_dispatch:
Expand All @@ -13,12 +13,12 @@ jobs:
- name: checkout
uses: actions/checkout@v3
with:
token: ${{secrets.BOT_TOKEN}}
ref: master

- name: Publish changelog
run: Tools/actions_changelogs_since_last_run.py
env:
BOT_TOKEN: ${{ secrets.BOT_TOKEN }}
CHANGELOG_DISCORD_WEBHOOK: ${{ secrets.CHANGELOG_DISCORD_WEBHOOK }}
CHANGELOG_DIR: ${{ vars.CHANGELOG_DIR }}
CHANGELOG_WEBHOOK: ${{ secrets.CHANGELOG_WEBHOOK }}
GITHUB_TOKEN: ${{ secrets.BOT_TOKEN }}
continue-on-error: true
1 change: 1 addition & 0 deletions Resources/Prototypes/_LostParadise/Maps/normandy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
MailCarrier: [ 1, 2 ]
SalvageSpecialist: [ 4, 4 ]
# Civilian
Passenger: [ -1, -1 ]
Clown: [ 1, 1 ]
Mime: [ 1, 1 ]
Musician: [ 1, 3 ]
Expand Down
19 changes: 9 additions & 10 deletions Tools/actions_changelogs_since_last_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,12 @@
GITHUB_API_URL = os.environ.get("GITHUB_API_URL", "https://api.github.com")
GITHUB_REPOSITORY = os.environ["GITHUB_REPOSITORY"]
GITHUB_RUN = os.environ["GITHUB_RUN_ID"]
BOT_TOKEN = os.environ["BOT_TOKEN"]
GITHUB_TOKEN = os.environ["GITHUB_TOKEN"]
CHANGELOG_DIR = os.environ["CHANGELOG_DIR"]
CHANGELOG_WEBHOOK = os.environ["CHANGELOG_WEBHOOK"]

# https://discord.com/developers/docs/resources/webhook
DISCORD_SPLIT_LIMIT = 2000
CHANGELOG_DISCORD_WEBHOOK = os.environ.get("CHANGELOG_DISCORD_WEBHOOK")

CHANGELOG_FILE = "Resources/Changelog/ChangelogLPP.yml"

TYPES_TO_EMOJI = {
"Fix": "🐛",
Expand All @@ -33,19 +32,19 @@
ChangelogEntry = dict[str, Any]

def main():
if not CHANGELOG_DISCORD_WEBHOOK:
if not CHANGELOG_WEBHOOK:
return

session = requests.Session()
session.headers["Authorization"] = f"Bearer {BOT_TOKEN}"
session.headers["Authorization"] = f"Bearer {GITHUB_TOKEN}"
session.headers["Accept"] = "Accept: application/vnd.github+json"
session.headers["X-GitHub-Api-Version"] = "2022-11-28"

most_recent = get_most_recent_workflow(session)
last_sha = most_recent['head_commit']['id']
print(f"Last successful publish job was {most_recent['id']}: {last_sha}")
last_changelog = yaml.safe_load(get_last_changelog(session, last_sha))
with open(CHANGELOG_FILE, "r") as f:
with open(CHANGELOG_DIR, "r") as f:
cur_changelog = yaml.safe_load(f)

diff = diff_changelog(last_changelog, cur_changelog)
Expand Down Expand Up @@ -93,7 +92,7 @@ def get_last_changelog(sess: requests.Session, sha: str) -> str:
"Accept": "application/vnd.github.raw"
}

resp = sess.get(f"{GITHUB_API_URL}/repos/{GITHUB_REPOSITORY}/contents/{CHANGELOG_FILE}", headers=headers, params=params)
resp = sess.get(f"{GITHUB_API_URL}/repos/{GITHUB_REPOSITORY}/contents/{CHANGELOG_DIR}", headers=headers, params=params)
resp.raise_for_status()
return resp.text

Expand Down Expand Up @@ -121,12 +120,12 @@ def get_discord_body(content: str):
def send_discord(content: str):
body = get_discord_body(content)

response = requests.post(CHANGELOG_DISCORD_WEBHOOK, json=body)
response = requests.post(CHANGELOG_WEBHOOK, json=body)
response.raise_for_status()


def send_to_discord(entries: Iterable[ChangelogEntry]) -> None:
if not CHANGELOG_DISCORD_WEBHOOK:
if not CHANGELOG_WEBHOOK:
print(f"No discord webhook URL found, skipping discord send")
return

Expand Down
Loading