Merge pull request #13 from bronxbot/dev #61
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 Notification | |
| on: | |
| push: | |
| branches: [main] | |
| jobs: | |
| notify: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 1 | |
| - name: Send Discord Embed | |
| run: | | |
| # Get raw commit message and convert GitHub formatting to Discord formatting | |
| RAW_MESSAGE=$(git log -1 --pretty=%B | sed 's/^> /➡️ /g; s/^- /• /g; s/\\n/\n/g') | |
| # Create Discord payload | |
| PAYLOAD=$(jq -n \ | |
| --arg author "${{ github.actor }}" \ | |
| --arg author_avatar "${{ github.actor_avatar_url }}" \ | |
| --arg message "$RAW_MESSAGE" \ | |
| --arg url "${{ github.event.head_commit.url }}" \ | |
| --arg timestamp "${{ github.event.head_commit.timestamp }}" \ | |
| '{ | |
| "embeds": [{ | |
| "title": "🚀 New Update Released!", | |
| "description": ("**Version:** 2.4.8a\n\n" + $message + "\n\n[View Full Changelog](" + $url + ")"), | |
| "color": 5763719, | |
| "footer": { | |
| "text": ("Pushed by " + $author), | |
| "icon_url": $author_avatar | |
| }, | |
| "timestamp": $timestamp | |
| }] | |
| }') | |
| # Send to Discord | |
| curl -X POST \ | |
| -H "Content-Type: application/json" \ | |
| -d "$PAYLOAD" \ | |
| "${{ secrets.DISCORD_WEBHOOK }}" |