]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Add more discord changelog logs (#23831)
authormetalgearsloth <31366439+metalgearsloth@users.noreply.github.com>
Wed, 10 Jan 2024 01:14:42 +0000 (12:14 +1100)
committerGitHub <noreply@github.com>
Wed, 10 Jan 2024 01:14:42 +0000 (02:14 +0100)
Tools/actions_changelogs_since_last_run.py

index 16d1260de0fcbb820852063e75287363c7449cb1..fde96f992c43592b76b48091612b366d8d660590 100755 (executable)
@@ -41,7 +41,7 @@ def main():
 
     most_recent = get_most_recent_workflow(session)
     last_sha = most_recent['head_commit']['id']
-    print(f"Last successsful publish job was {most_recent['id']}: {last_sha}")
+    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:
         cur_changelog = yaml.safe_load(f)
@@ -106,9 +106,12 @@ def diff_changelog(old: dict[str, Any], cur: dict[str, Any]) -> Iterable[Changel
 
 def send_to_discord(entries: Iterable[ChangelogEntry]) -> None:
     if not DISCORD_WEBHOOK_URL:
+        print(f"No discord webhook URL found, skipping discord send")
         return
 
     content = io.StringIO()
+    count: int = 0
+
     for name, group in itertools.groupby(entries, lambda x: x["author"]):
         content.write(f"**{name}** updated:\n")
         for entry in group:
@@ -116,10 +119,13 @@ def send_to_discord(entries: Iterable[ChangelogEntry]) -> None:
                 emoji = TYPES_TO_EMOJI.get(change['type'], "❓")
                 message = change['message']
                 url = entry.get("url")
+                count += 1
                 if url and url.strip():
                     content.write(f"{emoji} [-]({url}) {message}\n")
                 else:
                     content.write(f"{emoji} - {message}\n")
+    
+    print(f"Posting {count} changelog entries to discord webhook")
 
     body = {
         "content": content.getvalue(),
@@ -131,7 +137,8 @@ def send_to_discord(entries: Iterable[ChangelogEntry]) -> None:
         "flags": 1 << 2
     }
 
-    requests.post(DISCORD_WEBHOOK_URL, json=body)
+    response = requests.post(DISCORD_WEBHOOK_URL, json=body)
+    response.raise_for_status()
 
 
 main()