New dev webhook

This commit is contained in:
Willy-JL
2023-03-30 00:25:44 +01:00
parent 529483a18b
commit c87e354eb3
2 changed files with 57 additions and 0 deletions

41
.github/workflow_data/discord_push.py vendored Normal file
View File

@@ -0,0 +1,41 @@
#!/usr/bin/env python
import requests
import json
import os
if __name__ == "__main__":
with open(os.environ["GITHUB_EVENT_PATH"], "r") as f:
push = json.load(f)
count = len(push['commits'])
branch = push["ref"].removeprefix("refs/heads/")
change = "Force Push" if push["forced"] and not count else f"{count} New Commit{'' if count == 1 else 's'}"
desc = f"[**{change}**]({push['compare']}) on [{branch}]({push['repository']['html_url']}/tree/{branch}) branch\n"
for commit in push["commits"]:
desc += f"\n[`{commit['id'][:7]}`]({commit['url']}): {commit['message'].splitlines()[0]} - [__{commit['author']['username']}__](https://github.com/{commit['author']['username']})"
requests.post(
os.environ["DEV_DISCORD_WEBHOOK"],
headers={
"Accept": "application/json",
"Content-Type": "application/json"
},
json={
"content": None,
"embeds": [
{
"description": desc,
"url": push["compare"],
"color": 16711680 if push["forced"] else 3669797,
"author": {
"name": push["sender"]["login"],
"url": push["sender"]["html_url"],
"icon_url": push["sender"]["avatar_url"]
}
}
],
"attachments": []
}
)