Merge pull request #81 from VirtueSky/dev #5
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
| # .github/workflows/notify-discord-release.yml | ||
| 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: | | ||
| # Escape special characters in release notes | ||
| SAFE_NOTES="${{ github.event.release.body }}" | ||
| SAFE_NOTES="${SAFE_NOTES//\"/\\\"}" | ||
| SAFE_NOTES="${SAFE_NOTES//$'\n'/\\n}" | ||
| # Create timestamp | ||
| CREATED_AT="${{ github.event.release.created_at }}" | ||
| CREATED_AT="${CREATED_AT//T/ }" | ||
| CREATED_AT="${CREATED_AT//Z/ UTC}" | ||
| jq -n \ | ||
| --arg title "${{ github.event.release.name }}" \ | ||
| --arg tag "${{ github.event.release.tag_name }}" \ | ||
| --arg url "${{ github.event.release.html_url }}" \ | ||
| --arg author "${{ github.actor }}" \ | ||
| --arg notes "$SAFE_NOTES" \ | ||
| --arg created "$CREATED_AT" \ | ||
| --arg repo "${{ github.repository }}" \ | ||
| '{ | ||
| username: "GitHub Release Bot", | ||
| avatar_url: "https://github.githubassets.com/images/modules/logos_page/GitHub-Mark.png", | ||
| embeds: [ | ||
| { | ||
| title: "🚀 New Release Published", | ||
| url: $url, | ||
| color: 5793266, | ||
| author: { | ||
| name: $author, | ||
| icon_url: ("https://github.com/" + $author + ".png") | ||
| }, | ||
| fields: [ | ||
| {name: "Repository", value: $repo, inline: true}, | ||
| {name: "Tag", value: $tag, inline: true}, | ||
| {name: "Released at", value: $created, inline: false}, | ||
| {name: "Release Notes", value: (if $notes == "" then "No description" else $notes end), inline: false} | ||
| ], | ||
| footer: { | ||
| text: "GitHub Actions", | ||
| icon_url: "https://github.githubassets.com/images/modules/logos_page/GitHub-Mark.png" | ||
| }, | ||
| timestamp: (now | todate) | ||
| } | ||
| ] | ||
| }' > payload.json | ||
| curl -H "Content-Type: application/json" \ | ||
| -X POST \ | ||
| -d @payload.json \ | ||
| "$DISCORD_WEBHOOK_URL" | ||