Add new line to test53354 file #7
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Sticky Discord Notification | |
| on: | |
| push: | |
| branches: | |
| - main | |
| - master | |
| paths: | |
| - "sticky/**" | |
| jobs: | |
| discord: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Send latest Sticky commit to Discord | |
| env: | |
| DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK_STICKY }} | |
| COMMIT_MESSAGE: ${{ github.event.head_commit.message }} | |
| COMMIT_URL: ${{ github.event.head_commit.html_url }} | |
| AUTHOR: ${{ github.event.head_commit.author.name }} | |
| BRANCH: ${{ github.ref_name }} | |
| run: | | |
| python3 - <<'PY' | |
| import json | |
| import os | |
| import urllib.request | |
| payload = { | |
| "username": "GitHub Sticky", | |
| "embeds": [{ | |
| "title": "New Sticky Update", | |
| "description": os.environ["COMMIT_MESSAGE"][:4000], | |
| "url": os.environ["COMMIT_URL"], | |
| "color": 5814783, | |
| "fields": [ | |
| { | |
| "name": "Author", | |
| "value": os.environ["AUTHOR"] or "Unknown", | |
| "inline": True | |
| }, | |
| { | |
| "name": "Branch", | |
| "value": os.environ["BRANCH"], | |
| "inline": True | |
| } | |
| ] | |
| }] | |
| } | |
| request = urllib.request.Request( | |
| os.environ["DISCORD_WEBHOOK"], | |
| data=json.dumps(payload).encode("utf-8"), | |
| headers={ | |
| "Content-Type": "application/json", | |
| "User-Agent": "ToHubLab-Cogs/1.0 (+https://github.com/ToHubLab/ToHubLab-Cogs)" | |
| }, | |
| method="POST" | |
| ) | |
| try: | |
| with urllib.request.urlopen(request) as response: | |
| print("Discord HTTP", response.status) | |
| if response.status not in (200, 204): | |
| raise RuntimeError( | |
| f"Discord returned HTTP {response.status}" | |
| ) | |
| except urllib.error.HTTPError as e: | |
| print("Discord Fehler:", e.code, e.reason) | |
| print(e.read().decode("utf-8", errors="replace")) | |
| raise | |
| PY |