Skip to content

Instantly share code, notes, and snippets.

@SGTGunner
Created June 26, 2020 00:34
Show Gist options
  • Save SGTGunner/50d6a3cc0d489cf779f77695ba3e22ea to your computer and use it in GitHub Desktop.
Save SGTGunner/50d6a3cc0d489cf779f77695ba3e22ea to your computer and use it in GitHub Desktop.

Github to Discord Webhook Tutorial

In this tutorial I'll show you how to create a Github webhook that will post updates from your Github account to a channel in Discord. The steps are simple so follow along!

Create a Webhook in a Discord Channel

First you need to create a webhook in a text channel. We're assuming you have both Manage Channel and Manage Webhooks permissions!

  • Go in a channel properties (Alternatively, Server Settings, Webhooks works too)
  • Click Webhooks
  • Click Create Webhook
  • Type in a name (this is for local reference, it's overriden by the incoming hook data)
  • Copy the Webhook URL (you can use the Copy button)
  • Click Save

WebhookDiscord

Note: Do NOT give the Webhook URL out to the public. Anyone or service can post messages to this channel, without even needing to be in the server. Keep it safe!

Create the Github Webhook

In order to do this you need to be the owner of the github repository. Even Collaborators cannot access settings.

  • Click on Settings
  • Click on Webhooks
  • Click on Add Webhook
  • The Payload URL is the webhook URL with /github added to the end.
  • Leave Secret blank, change the Content-Type to application/json
  • Select what type of events you want
  • Click Add Webhook

WebhookGithub

Note: The "test" payload will not show anything in your channel. That is normal. You will need to actually take an action in order to show any activity. However, make sure the test payload has a green checkmark, and the response is 204.

Troubleshooting

I'm getting a 400 error!

Make sure to add /github at the end of the webhook URL.

Can I change the Avatar and Name of the hook's messages?

No, Github controls that part, so they're choosing the name and Avatar.

I'm not getting the events I want (or too many)

Under Which events would you like to trigger this webhook?, select Let me select individual events.

Check the events you'd like to receive. There are a lot of them.

Enjoy!

That's it. That's all you had to do. Now go code!

@faceless613
Copy link

Thanks

@jonaspleyer
Copy link

Worked like a charm for me. Thank you!

@vycos-zen
Copy link

thank you

@sunnamed434
Copy link

sunnamed434 commented Sep 16, 2023

If you get 400/404, simply make a Commit in this repo and if you see a message in discord webhook then its fine

@Sp1d3rmanj0e
Copy link

Thank you!

@Coding4Hours
Copy link

Thank you!

@Milkywayrules
Copy link

ah, thank you, dude!

@MintedLizardGutz
Copy link

nvm how do I insert the webhook to discord

@jhelmink
Copy link

You might want to update this to note that only certain events will come through (despite getting a 204 response)

discord/discord-api-docs#6203 (comment)

No plans to add to the list :(

@MadalitsoNyemba
Copy link

Works great👌

@zobbo
Copy link

zobbo commented Mar 9, 2024

Followed and worked first time. Many thanks!

@s-sajib
Copy link

s-sajib commented May 18, 2024

Thanks a ton. I forget to place the /github at the end every time!

@roklasik
Copy link

roklasik commented Jun 6, 2024

Thank you ^^

@NicPWNs
Copy link

NicPWNs commented Jun 17, 2024

Hello all past and future!

For those running into issues (like myself), I made a Discord bot to make this process a bit easier: GitHub Bot for Discord.

Just add the bot to your Discord server and use /github commands to create/delete subscriptions to various GitHub repo events. It uses the minimum permissions needed and should help make this process easier! ✅

@fretanm
Copy link

fretanm commented Aug 26, 2024

I'm still confused what do I search up ?

@josfam
Copy link

josfam commented Aug 27, 2024

Thanks.
Works like a charm.

@thuanvoit
Copy link

Thank you!

@Nhanzdeptrai
Copy link

Tétt

@joblessgod
Copy link

Can we customize it or not? If yes, how?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment