Discord Notification Workflow β
Status: β
Production
Workflow File: .github/workflows/discord-notify.yml
Type: Push notification automation
Triggers: Commits to main, dev, and all branches (for testing)
Overview β
The Discord Notification workflow automatically sends commit notifications to a Discord channel whenever code is pushed to the repository. This keeps the team informed of code changes in real-time without requiring manual updates.
Key Features:
- Multi-commit support: Shows all commits when multiple are pushed at once
- Commit count in title (e.g., "3 commits")
- Shows commit message, author, and shortened SHA for each commit
- Direct links to each commit on GitHub
- Color-coded by branch:
- Blue (
#5865F2) formainbranch - Green (
#57F287) fordevbranch
- Blue (
- Timestamp of push
- Commits separated by horizontal rules for clarity
- Notification history tracking to avoid duplicate messages
Quick Setup β
1. Create Discord Webhook β
- Open Discord Server Settings β Integrations β Webhooks
- Click "New Webhook"
- Name:
GitHub Notifications - Select channel where notifications should appear (e.g.,
#dev-updates) - Copy the webhook URL
2. Add GitHub Secrets β
- Go to GitHub repository secrets
- Click "New repository secret"
- Name:
DISCORD_WEBHOOK_COMMITS - Value: Paste the production commit-notification webhook URL (used on
dev/main) - (Optional) Add
DISCORD_WEBHOOK_TESTfor feature branches if you want non-prod pushes in a separate channel - Click "Add secret"
3. Test β
Push a commit to dev or main branch:
git commit -m "Test Discord notification"
git push origin devThen check:
- GitHub Actions tab for workflow status
- Your Discord channel for the notification
Notification Behavior β
When Notifications Fire β
- Any push to
mainbranch - Any push to
devbranch - Any push to any other branch (useful for testing or feature branch tracking)
What Gets Notified β
Per Commit:
- Commit message
- Author name
- Shortened commit SHA (7 characters)
- Link to commit on GitHub
Per Push:
- Total commit count
- Branch name
- Timestamp
Avoiding Duplicates β
The workflow maintains a notification history in git to prevent sending the same commit notification twice. This is stored in .github-workflow-state/notified-commits.txt and persists across workflow runs.
Troubleshooting β
Notifications Not Appearing β
Check:
- Secret exists: Verify
DISCORD_WEBHOOK_COMMITS(andDISCORD_WEBHOOK_TESTif used) are set in GitHub secrets - Webhook URL valid: Test by sending a test message via Discord webhook
- Permissions: Ensure bot/webhook has permission to post in the target channel
- Branches: Ensure you're pushing to
mainordev(or another branch if configured)
Duplicate Notifications β
- The workflow includes deduplication logicβduplicates should not occur
- If duplicates happen, check
.github-workflow-state/notified-commits.txtin git history - May need to reset notification history by removing that file from git
Wrong Channel β
- Verify the webhook URL points to the correct Discord channel
- Update the webhook URL in GitHub secrets if the channel changed
Configuration β
Environment Variables (in Workflow) β
No environment variablesβall configuration is via:
DISCORD_WEBHOOK_COMMITSsecret (required fordev/main)DISCORD_WEBHOOK_TESTsecret (optional for non-prod branches)- Workflow trigger branches (currently
main,dev,**)
Customization β
To change notification content or formatting:
- Edit
.github/workflows/discord-notify.yml - Modify the "Prepare commit messages" step to change message format
- Modify the "Send to Discord" step to change embed styling
To add more branches:
- Edit the
on.push.branchessection in.github/workflows/discord-notify.yml
Related Documentation β
- Discord Webhooks Setup Guide β Detailed setup and troubleshooting
- Discord Bot Documentation β For the full Discord bot service (separate from this workflow)
Testing Locally β
There is no local testing needed for this workflowβit only runs on GitHub Actions when code is pushed.
To test the webhook URL:
curl -X POST "YOUR_WEBHOOK_URL" \
-H "Content-Type: application/json" \
-d '{
"content": "Test message",
"embeds": [{
"title": "Test Commit",
"description": "This is a test notification"
}]
}'Maintenance β
Regular Checks β
- Monthly: Verify webhook URL is still valid and bot still has permissions
- On channel changes: Update webhook URL in GitHub secrets
Updating the Workflow β
If modifying the workflow, test on a non-production branch first:
git checkout -b test/discord-workflow
# Make changes to .github/workflows/discord-notify.yml
git push origin test/discord-workflow
# Verify notifications work
# Then merge to dev and mainRelated Files β
.github/workflows/
βββ discord-notify.yml # Workflow definition
.github/workflow-state/
βββ notified-commits.txt # Notification history (auto-managed)
docs/engineering/github/workflows/
βββ DISCORD_NOTIFICATION.md # This file
βββ discord/
β βββ IMPLEMENTATION_SUMMARY.md # Quick reference
βββ testing/
βββ (See testing docs for workflow validation)