Add new line with content to test53354 #4
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: Checkout repository | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Check changed files | |
| id: changes | |
| run: | | |
| if [ "${{ github.event.before }}" = "0000000000000000000000000000000000000000" ]; then | |
| # Neuer Branch: Alle Dateien im Push als geändert betrachten | |
| CHANGED_FILES=$(git diff --name-only "${{ github.event.after }}^" "${{ github.event.after }}" 2>/dev/null || echo "") | |
| else | |
| CHANGED_FILES=$(git diff --name-only "${{ github.event.before }}" "${{ github.event.after }}") | |
| fi | |
| echo "Geänderte Dateien:" | |
| echo "$CHANGED_FILES" | |
| if echo "$CHANGED_FILES" | grep -q "^sticky/"; then | |
| echo "has_sticky_changes=true" >> $GITHUB_OUTPUT | |
| else | |
| echo "has_sticky_changes=false" >> $GITHUB_OUTPUT | |
| fi | |
| - name: Send latest Sticky commit to Discord | |
| if: steps.changes.outputs.has_sticky_changes == 'true' | |
| 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 |