Integrate GitHub and Discord with Webhooks
Date Published: 30 April 2020
It's worked quite well and is completely free for our needs. You can easily add bots and notifications from other systems, including your own ASP.NET web applications, using web hooks.
One of the easier ways to configure notifications from things you care about as a developer to your Discord server is with GitHub web hooks. There's a great write-up on how to do this here, which I'm basically enhancing here for my own purposes (and in case that resource ever disappears).
Configure Discord Webhooks
First, you need to have a Discord server. If you don't have one,you can set one up for free. Once you have a server set up, I recommend configuring a text channel just for your GitHub notifications:
A private text channel for GitHub updates in Discord.
You can tweak the settings on the channel to control who should or shouldn't have access to it. Then, click on Webhooks menu option and create a new webhook:
Create a webhook in Discord.
The important thing is the URL at the bottom. Copy that to your clipboard. Then you can exit out of the settings and just watch the channel, which should start to have content automatically added to it once you complete the next steps.
Configure GitHub Webhooks
Now go to GitHub, sign in, and navigate to one of your repositories from which you'd like to receive notifications in Discord. Click on Settings and choose the Webhooks menu:
Although nothing really jumps out and says it, GitHub is the producer of events and Discord is the consumer. Discord provides the URL for the Webhook, and you provide this URL to GitHub so that GitHub can make requests to this URL whenever something of interest happens.
Next, choose Add webhook from the GitHub settings page.
Add webhook details to GitHub.
Paste in the URL from Discord. Add
/github to the end of it. Be sure to change the Content type to
application/json. Change the radio button to "Send me everything" and then click the Add webhook button.
At this point, you should be notified whenever anything happens with this repository. You can always dial it down later if it gets to be too much noise. To test it out, try starring and unstarring your repository, or adding a comment to an issue. Any of these should trigger notifications in your Discord channel.
Steve is an experienced software architect and trainer, focusing currently on ASP.NET Core and Domain-Driven Design.