Skip to content
Open
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
2 changes: 1 addition & 1 deletion .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<!-- Summary of code changes for easier review. -->

## Media
<!-- Attach media if the PR makes in-game changes (clothing, items, features, etc). -->
<!-- Attach media if the PR makes in-game changes (clothing, items, features, etc). The first image you attach will be posted to the discord changelog.-->

## Requirements
<!-- Confirm the following by placing an X in the brackets without spaces inside (for example: [X] ): -->
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,13 @@ jobs:

- name: Publish changelog (Discord)
continue-on-error: true
run: Tools/actions_changelogs_since_last_run.py
run: Tools/changelogs/actions_changelogs_since_last_run.py
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
DISCORD_WEBHOOK_URL: ${{ secrets.CHANGELOG_DISCORD_WEBHOOK }}

- name: Publish changelog (RSS)
continue-on-error: true
run: Tools/actions_changelog_rss.py
run: Tools/changelogs/actions_changelog_rss.py
env:
CHANGELOG_RSS_KEY: ${{ secrets.CHANGELOG_RSS_KEY }}
228 changes: 0 additions & 228 deletions Tools/actions_changelogs_since_last_run.py

This file was deleted.

File renamed without changes.
62 changes: 62 additions & 0 deletions Tools/changelogs/actions_changelogs_since_last_run.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
#!/usr/bin/env python3

"""
Sends updates to a Discord webhook for new changelog entries since the last GitHub Actions publish run.

Automatically figures out the last run and changelog contents with the GitHub API.
"""

import requests # REMOVE

from changelog_helperfunctions import log, get_pr_json, grab_image_urls_from_pr_body, validate_environment, create_session, get_changes, send_discord_webhook, TYPES_TO_EMOJI


def main():
if not validate_environment():
exit(1)

sess: requests.Session = create_session()
changes = get_changes(sess)

data = {"embeds": []}
embed_count: int = 0

for author, changes, id, time, url in (entry.values() for entry in changes):
if embed_count >= 10: # discord allows up to 10 embeds per message
if not send_discord_webhook(data):
exit(1)
embed_count = 0
data = {"embeds": []}

pr = get_pr_json(sess, url)

if not pr:
log.error(f"Could not find the pull request from: {url}")

embed = {
"title": f"{author}",
"thumbnail": {"url": pr["user"]["avatar_url"]},
"description": f"### {pr["title"]} [[PR]]({url})",
"color": int("#81BABA"[1:], base=16), # embeds want an integer color representation for some reason, this allows you to put in a hex value in code and have a preview of the color in your ide
# change this to whatever color fits your repository
"fields": []
}

images = grab_image_urls_from_pr_body(pr["body"])
if images:
embed.update({"image": { "url": images[0] }}) # maybe discord adds nice multi-image embed support later down the line, for now, only the first image.
else:
log.info(f"Could not find any images in pull request at: {url}")

for message, type in ((change["message"], change["type"]) for change in changes):
emoji = TYPES_TO_EMOJI.get(type, "❓")
embed["fields"].append({"name":f"", "value":f"{emoji} - {message}"})

data["embeds"].append(embed)
embed_count += 1

return


if __name__ == "__main__":
main()
Loading
Loading