Add new line to sticky/test53354 #5
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"}, | |
| method="POST" | |
| ) | |
| with urllib.request.urlopen(request) as response: | |
| if response.status not in (200, 204): | |
| raise RuntimeError( | |
| f"Discord returned HTTP {response.status}" | |
| ) | |
| PY |