update 3.5.5-preview #11
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 or Tag | |
| on: | |
| release: | |
| types: [published] | |
| push: | |
| tags: | |
| - '*' | |
| jobs: | |
| notify-discord: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Send release/tag info to Discord | |
| env: | |
| DISCORD_WEBHOOK_URL: ${{ secrets.DISCORD_WEBHOOK_URL }} | |
| EVENT_NAME: ${{ github.event_name }} | |
| RELEASE_TITLE: ${{ github.event.release.name }} | |
| RELEASE_TAG_NAME: ${{ github.event.release.tag_name }} | |
| RELEASE_NOTE: ${{ github.event.release.body }} | |
| RELEASE_AUTHOR: ${{ github.event.release.author.login }} | |
| PUSH_TAG_NAME: ${{ github.ref_name }} | |
| REPO: ${{ github.repository }} | |
| ACTOR: ${{ github.actor }} | |
| run: | | |
| if [ "$EVENT_NAME" = "release" ]; then | |
| TITLE="${RELEASE_TITLE:-No release title}" | |
| TAG="${RELEASE_TAG_NAME:-Unknown tag}" | |
| NOTE="${RELEASE_NOTE}" | |
| AUTHOR="${RELEASE_AUTHOR:-$ACTOR}" | |
| EVENT_LABEL="GitHub Release" | |
| else | |
| TITLE="Tag created" | |
| TAG="${PUSH_TAG_NAME:-Unknown tag}" | |
| NOTE="A new tag was pushed without creating a GitHub Release." | |
| AUTHOR="$ACTOR" | |
| EVENT_LABEL="Git Tag" | |
| fi | |
| if [ -z "$NOTE" ]; then | |
| NOTE="(empty)" | |
| fi | |
| if [ ${#NOTE} -gt 1000 ]; then | |
| NOTE="${NOTE:0:1000}..." | |
| fi | |
| jq -n \ | |
| --arg event "$EVENT_LABEL" \ | |
| --arg title "$TITLE" \ | |
| --arg tag "$TAG" \ | |
| --arg note "$NOTE" \ | |
| --arg repo "$REPO" \ | |
| --arg actor "$ACTOR" \ | |
| --arg author "$AUTHOR" \ | |
| '{ | |
| embeds: [ | |
| { | |
| title: $event, | |
| fields: [ | |
| { "name": "Repository", "value": $repo, "inline": false }, | |
| { "name": "Triggered By", "value": $actor, "inline": false }, | |
| { "name": "Author", "value": $author, "inline": false }, | |
| { "name": "Title", "value": $title, "inline": false }, | |
| { "name": "Tag Name", "value": $tag, "inline": false }, | |
| { "name": "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" |