VOIP-1290-Fix-webhook-signature-and-security-issues #748
Workflow file for this run
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: Discord Merge Notification | |
| on: | |
| pull_request: | |
| types: [closed] | |
| branches: [main] | |
| jobs: | |
| notify: | |
| if: github.event.pull_request.merged == true | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Send Discord Notification | |
| env: | |
| DISCORD_WEBHOOK_URL: ${{ secrets.DISCORD_WEBHOOK_URL }} | |
| PR_TITLE: ${{ github.event.pull_request.title }} | |
| PR_BODY: ${{ github.event.pull_request.body }} | |
| PR_AUTHOR: ${{ github.event.pull_request.user.login }} | |
| PR_URL: ${{ github.event.pull_request.html_url }} | |
| PR_REPO: ${{ github.repository }} | |
| run: | | |
| # Truncate body if too long (Discord embed field limit is 1024 chars) | |
| TRUNCATED_BODY="${PR_BODY:0:1000}" | |
| if [ ${#PR_BODY} -gt 1000 ]; then | |
| TRUNCATED_BODY="${TRUNCATED_BODY}..." | |
| fi | |
| # Build JSON payload with jq for proper escaping | |
| PAYLOAD=$(jq -n \ | |
| --arg title "$PR_TITLE" \ | |
| --arg body "$TRUNCATED_BODY" \ | |
| --arg author "$PR_AUTHOR" \ | |
| --arg url "$PR_URL" \ | |
| --arg repo "$PR_REPO" \ | |
| '{ | |
| embeds: [{ | |
| title: "🔀 PR Merged to main", | |
| color: 5763719, | |
| fields: [ | |
| { name: "Repository", value: $repo, inline: false }, | |
| { name: "Title", value: $title, inline: false }, | |
| { name: "Author", value: $author, inline: true }, | |
| { name: "Description", value: ($body // "No description"), inline: false }, | |
| { name: "Link", value: $url, inline: false } | |
| ] | |
| }] | |
| }') | |
| curl -H "Content-Type: application/json" \ | |
| -X POST \ | |
| -d "$PAYLOAD" \ | |
| "$DISCORD_WEBHOOK_URL" |