Add new line with special characters to test53354 #8
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 }} | |
| COMMIT_SHA: ${{ github.event.head_commit.id }} | |
| AUTHOR: ${{ github.event.head_commit.author.name }} | |
| AUTHOR_URL: https://github.com/${{ github.event.head_commit.author.username }} | |
| BRANCH: ${{ github.ref_name }} | |
| REPO_URL: ${{ github.server_url }}/${{ github.repository }} | |
| run: | | |
| python3 - <<'PY' | |
| import json | |
| import os | |
| import urllib.request | |
| import urllib.error | |
| sha = os.environ["COMMIT_SHA"] | |
| repo_url = os.environ["REPO_URL"] | |
| commit_url = os.environ["COMMIT_URL"] | |
| author_url = os.environ["AUTHOR_URL"] | |
| # Direktlink auf die geänderten Dateien des Commits | |
| files_url = f"{commit_url}/files" | |
| payload = { | |
| "username": "GitHub Sticky", | |
| "embeds": [{ | |
| "title": "New Sticky Update", | |
| "description": os.environ["COMMIT_MESSAGE"][:4000], | |
| "url": commit_url, | |
| "color": 5814783, | |
| "fields": [ | |
| { | |
| "name": "Author", | |
| "value": f"[{os.environ['AUTHOR'] or 'Unknown'}]({author_url})", | |
| "inline": True | |
| }, | |
| { | |
| "name": "Branch", | |
| "value": f"[{os.environ['BRANCH']}]({repo_url}/tree/{os.environ['BRANCH']})", | |
| "inline": True | |
| }, | |
| { | |
| "name": "Links", | |
| "value": ( | |
| f"[Commit `{sha[:7]}`]({commit_url}) · " | |
| f"[Änderungen ansehen]({files_url}) · " | |
| f"[Vergleich mit vorherigem Commit]({repo_url}/compare/${{ github.event.before }}...{sha})" | |
| ), | |
| "inline": False | |
| } | |
| ] | |
| }] | |
| } | |
| 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) | |
| except urllib.error.HTTPError as e: | |
| print("Discord Fehler:", e.code, e.reason) | |
| print(e.read().decode("utf-8", errors="replace")) | |
| raise | |
| PY |