deps: bump the github-actions group with 3 updates #234
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: Notify Discord | |
| "on": | |
| pull_request: | |
| types: | |
| - opened | |
| - ready_for_review | |
| permissions: | |
| contents: read | |
| jobs: | |
| notify-discord: | |
| # Draft pull requests wait until ready_for_review so Discord only receives | |
| # notifications for PRs that are ready for broader attention. | |
| if: ${{ !github.event.pull_request.draft }} | |
| runs-on: ubuntu-24.04 | |
| timeout-minutes: 5 | |
| env: | |
| DISCORD_WEBHOOK_URL: ${{ secrets.DISCORD_WEBHOOK_URL }} | |
| steps: | |
| - name: Skip when webhook is not configured | |
| if: ${{ env.DISCORD_WEBHOOK_URL == '' }} | |
| run: > | |
| echo "DISCORD_WEBHOOK_URL is not configured; | |
| skipping Discord notification." | |
| - name: Send Discord Message | |
| if: ${{ env.DISCORD_WEBHOOK_URL != '' }} | |
| env: | |
| PR_TITLE: ${{ github.event.pull_request.title }} | |
| PR_BODY: ${{ github.event.pull_request.body }} | |
| PR_URL: ${{ github.event.pull_request.html_url }} | |
| run: | | |
| set -euo pipefail | |
| payload="$( | |
| python3 - <<'PY' | |
| import json | |
| import os | |
| title = os.environ.get("PR_TITLE") or "Pull request notification" | |
| description = ( | |
| os.environ.get("PR_BODY") or | |
| "No pull request description provided." | |
| ) | |
| url = os.environ.get("PR_URL") or "" | |
| print(json.dumps({ | |
| "allowed_mentions": { | |
| "parse": [], | |
| }, | |
| "embeds": [ | |
| { | |
| "title": title[:256], | |
| "description": description[:4096], | |
| "url": url, | |
| }, | |
| ], | |
| })) | |
| PY | |
| )" | |
| curl \ | |
| --fail-with-body \ | |
| --silent \ | |
| --show-error \ | |
| --request POST \ | |
| --header "Content-Type: application/json" \ | |
| --data "$payload" \ | |
| "$DISCORD_WEBHOOK_URL" |