Notify Discord on Release or Tag #6
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: Notify Discord on Release | |
| on: | |
| release: | |
| types: [published] | |
| jobs: | |
| notify-discord: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Send release info to Discord | |
| env: | |
| DISCORD_WEBHOOK_URL: ${{ secrets.DISCORD_WEBHOOK_URL }} | |
| run: | | |
| RELEASE_TITLE="${{ github.event.release.name }}" | |
| TAG_NAME="${{ github.event.release.tag_name }}" | |
| RELEASE_NOTE="${{ github.event.release.body }}" | |
| if [ -z "$RELEASE_NOTE" ]; then | |
| RELEASE_NOTE="(empty)" | |
| fi | |
| if [ ${#RELEASE_NOTE} -gt 1000 ]; then | |
| RELEASE_NOTE="${RELEASE_NOTE:0:1000}..." | |
| fi | |
| jq -n \ | |
| --arg title "$RELEASE_TITLE" \ | |
| --arg tag "$TAG_NAME" \ | |
| --arg note "$RELEASE_NOTE" \ | |
| '{ | |
| embeds: [ | |
| { | |
| title: "GitHub Release", | |
| fields: [ | |
| { "name": "Release Title", "value": $title, "inline": false }, | |
| { "name": "Tag Name", "value": $tag, "inline": false }, | |
| { "name": "Release Note", "value": $note, "inline": false } | |
| ] | |
| } | |
| ] | |
| }' > payload.json | |
| cat payload.json | |
| curl --fail-with-body \ | |
| -H "Content-Type: application/json" \ | |
| -X POST \ | |
| -d @payload.json \ | |
| "$DISCORD_WEBHOOK_URL" |