updated Discord integration

This commit is contained in:
cskonopka
2025-11-16 22:10:05 -05:00
parent e69514ae3f
commit 39a9bda75b

View File

@@ -5,42 +5,41 @@ on:
branches:
- main
- experimental
# add other branches if you want
# add other branches here if you like
jobs:
notify:
runs-on: ubuntu-latest
steps:
- name: Get last commit info
id: last_commit
run: |
echo "message=$(echo '${{ github.event.head_commit.message }}' | sed 's/"/'\''/g')" >> $GITHUB_OUTPUT
- name: Send notification to Discord
env:
DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }}
run: |
# Basic context from GitHub
repo="${{ github.repository }}"
pusher="${{ github.actor }}"
branch="${{ github.ref_name }}"
commit_url="${{ github.event.head_commit.url }}"
commit_msg="${{ steps.last_commit.outputs.message }}"
payload=$(cat <<EOF
# Commit message, safely JSON-escaped via toJSON
commit_title=${{ toJSON(github.event.head_commit.message) }}
# Build the Discord payload
read -r -d '' payload <<EOF
{
"content": "**${repo}** updated on branch **${branch}** by **${pusher}**",
"embeds": [
{
"title": "Latest Commit",
"description": "${commit_msg}",
"title": ${commit_title},
"description": "View this commit on GitHub",
"url": "${commit_url}"
}
]
}
EOF
)
# Send to Discord
curl -X POST \
-H "Content-Type: application/json" \
-d "$payload" \