This guide shows you how to automatically post a message to a Discord channel every time you push changes to a GitHub repository. You’ll set up a Discord webhook and configure GitHub to send a notification whenever a push occurs. You’ll need a GitHub repository (public or private) and a Discord server where you have permission to manage webhooks.
What You’ll Need
- A GitHub account with a repository you want to monitor.
- A Discord server where you have “Manage Webhooks” permission (usually requires the “Manage Server” permission).
- Basic familiarity with navigating GitHub and Discord settings.
Step-by-Step
- Create a Discord Webhook
- Open Discord and go to your server.
- Click the server name at the top-left, then select Server Settings.
- In the left sidebar, click Integrations.
- Click Webhooks, then New Webhook.
- Give the webhook a name (e.g., “GitHub Pushes”) and choose the channel where you want notifications to appear.
- Click Copy Webhook URL and save it somewhere safe. You’ll need it in step 3.
- Open Your GitHub Repository
- Go to github.com and open the repository you want to monitor.
- Click the Settings tab (the gear icon) near the top-right of the repository page.
- Add the Webhook to GitHub
- In the left sidebar, click Webhooks.
- Click the Add webhook button.
- In the Payload URL field, paste the Discord webhook URL you copied earlier.
- Change Content type to
application/json. - Under Which events would you like to trigger this webhook?, select Just the push event (or choose “Let me select individual events” and check only “Pushes”).
- Leave Active checked.
- Click Add webhook.
- Test the Webhook
- After adding, GitHub shows the webhook in the list. Click on it.
- Scroll down to Recent Deliveries. You should see a red or green entry. Click Redeliver (or click the delivery and then “Redeliver”) to send a test ping.
- Check your Discord channel: you should see a message like “Test message” or a generic push notification. If you don’t see anything, check the delivery response for errors.
- Make a Real Push
- Commit a change to your repository and push it to GitHub (e.g.,
git push origin main). - Within a few seconds, a message should appear in your Discord channel, showing the commit details, author, and a link to the commit.
- Commit a change to your repository and push it to GitHub (e.g.,
Common Mistakes
- Wrong content type: If you leave the content type as
application/x-www-form-urlencoded, Discord won’t parse the payload correctly. Always set it toapplication/json. - Webhook URL copied incorrectly: Make sure you copy the entire URL, including the random part at the end. A missing character will cause the webhook to fail.
- Selecting too many events: If you choose “Send me everything,” you’ll get notifications for issues, pull requests, stars, etc., not just pushes. Stick to “Just the push event” for clean push-only updates.
- Webhook disabled: If you accidentally uncheck “Active” after creating, the webhook won’t fire. Check the toggle.
Tips
- Customize the message: You can create a custom message by using a GitHub Action or a service like Zapier, but the default webhook gives a decent push notification with commit details.
- Use a dedicated channel: Create a separate Discord channel (e.g., #github-logs) to avoid cluttering general chat.
- Secure your webhook: Anyone with the webhook URL can send messages to that channel. Treat it like a password—don’t commit it to public repos.
- Check delivery status: If a push doesn’t appear, go to the webhook settings and click “Recent Deliveries” to see the HTTP response. A 204 response means success; 4xx or 5xx indicates an issue.
Troubleshooting
- No message appears after a push:
- Go to the webhook in GitHub, click it, and scroll to Recent Deliveries. Look for the latest delivery and click it to see the response. If the status is 4xx or 5xx, read the error message.
- Common error:
400 Bad Requestmeans the payload URL is malformed or the content type is wrong. Double-check both. - If the delivery shows
304 Not Modified, that’s normal; it means the webhook was received but no message was sent (e.g., a ping).
- Message appears but is empty or garbled:
- This usually happens if the content type is not
application/json. Update the webhook settings and try again.
- This usually happens if the content type is not
- Webhook works but only for some pushes:
- Check if you have branch protection rules that might block the push from triggering the webhook. Webhooks fire on any push event, but if the push is rejected, no event is sent.
- Discord webhook URL expired:
- Webhooks don’t expire, but if you delete the webhook in Discord, the URL becomes invalid. Recreate it and update GitHub.
Frequently Asked Questions
Can I send push updates for only a specific branch?
Yes. In the webhook settings, you can add a branch filter (under “Which events”) by selecting “Let me select individual events” and then choosing “Pushes” and entering a branch name. Only pushes to that branch will trigger the webhook.
Will the webhook send commit messages or just a notification?
By default, Discord’s GitHub webhook sends a rich embed with the commit message, author, and a link to the commit. It does not send the full diff.
Can I use this for a private repository?
Yes, webhooks work for private repositories as long as the repository is on GitHub (free or paid plans). The webhook URL is secret, so only those with access to the repo settings can see it.
How do I remove the webhook later?
Go to the repository Settings > Webhooks, find the webhook, and click Delete. Also delete the webhook in Discord Server Settings > Integrations > Webhooks to fully remove it.
Can I send push updates to multiple Discord channels?
Yes. Create multiple webhooks in Discord (one per channel) and add each as a separate webhook in GitHub. Each will fire independently.
What if I want a custom message format?
Use a GitHub Action like actions/github-script to send a custom HTTP request to the Discord webhook with your own JSON payload. This gives full control over the message content.
Related
General steps for current mainstream versions; menus can differ by device and version. See the disclaimer or report an error.
More in this bed
- Fix Outlook Sent Items Missing? Quick Solutions
- Fix Missing Scroll Bar in Chrome
- Fix Sony Vegas Crashing on Windows 10
- Hide WhatsApp Channel: Android & iOS Guide
- Slow Context Menu in Windows 11: Fixes
- Declutter Safari on iPhone: 15 Quick Tips