Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Simple Github -> Discord webhook

Step 1 - Make a Discord Webhook

  1. Find the Discord channel in which you would like to send commits and other updates

  2. In the settings for that channel, find the Webhooks option and create a new webhook. Note: Do NOT give this 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! WebhookDiscord

Step 2 - Set up the webhook on Github

  1. Navigate to your repository on Github, and open the Settings Settings

  2. Select Add Webhook Add

  3. Paste in the webhook url and append /github to the end. Select "Send me everything", set the type to application/json, and then Add Webhook WebhookSettings

  4. Test it by updating something or starring the repository! If it works, you're all set! Star

@JanCVanB
Copy link

JanCVanB commented Jan 27, 2022

@Nexuzzzz's guide worked for me, and it still works after enabling SSL.

@Joseph11024
Copy link

Joseph11024 commented Jan 28, 2022

Does this only work for my own repositories or can I set it up to get updates from other repositories that I follow as well?

@ShanuDey
Copy link

ShanuDey commented Jan 29, 2022

Thank you so much. It worked!

@dietmerc
Copy link

dietmerc commented Feb 7, 2022

does anyone know of a way to forward your github feed & watch subscriptions to a webhook?

@CIT-Michael
Copy link

CIT-Michael commented Feb 9, 2022

Thank you this is really helps to figure it out what's wrong with discord setting

@rihp
Copy link

rihp commented Feb 14, 2022

ez guide

@rihp
Copy link

rihp commented Feb 14, 2022

ty

@realguystuff
Copy link

realguystuff commented Mar 11, 2022

What is SSL?

@McJoe21
Copy link

McJoe21 commented Mar 11, 2022

What is SSL?

Https thing

@yauri-io
Copy link

yauri-io commented Mar 19, 2022

Discord has rate limiting. Look on the response header

Example:
X-Ratelimit-Limit: 5 --> this is the limit of request can be sent / second
X-Ratelimit-Remaining: 3
X-Ratelimit-Reset: 1647670811
X-Ratelimit-Reset-After: 2

@SlZeroth
Copy link

SlZeroth commented Mar 22, 2022

thank you :)

@Gesugao-san
Copy link

Gesugao-san commented May 23, 2022

Updated with dark theme

image

@Zamiell
Copy link

Zamiell commented May 25, 2022

Can someone tell me How I can set it that it sends only pushes of one branch?

@MasaiasuOse I'm looking for the same thing. I don't think it's possible without building your own bot to intercept the hook and only let certain messages through. Let me know if you find an existing solution.

@Potaot
Copy link

Potaot commented Jun 8, 2022

Can someone tell me How I can set it that it sends only pushes of one branch?

@MasaiasuOse I'm looking for the same thing. I don't think it's possible without building your own bot to intercept the hook and only let certain messages through. Let me know if you find an existing solution.

You should click on 'let me select individual events' option instead of 'send me everything'

@Padmanabh82
Copy link

Padmanabh82 commented Jun 16, 2022

@jagrosh hi, i want to build same bot like this (but it will post custom github messages) instead of making a webhook, is that possible???

@Zamiell
Copy link

Zamiell commented Jun 16, 2022

You should click on 'let me select individual events' option instead of 'send me everything'

@Potaot That doesn't solve the problem of only getting commits from one branch. Maybe you can elaborate further.

@fiizzy
Copy link

fiizzy commented Jun 20, 2022

Heyy guys, here is my issue:

All of a sudden my Github webhook has stopped firing events. In the recent deliveries tab, it doesn't even show that an event was triggered by github itself, when in fact I have made a pus/commit etc.

It seem more like a github issue, as my netlify has also stopped automatically building. So I'm guessing GH isn't sending any POST req. from my organization.

Don't know how or why that is happening.
Any suggestions would be appreciated.

@jonesXYZ
Copy link

jonesXYZ commented Jun 20, 2022

same here.

@fiizzy
Copy link

fiizzy commented Jun 20, 2022

Heyy @jonesXYZ , I just tried a push again this evening [ after about 24hrs since I noticed ] and the webhook is once again sending to the discord channel and my netlify builds are automatically deploying based on my GH pushes/PRs.

So, my best guess is that it was a github thingy.
Have you tried yours recently to see if it works ?

@maxmandia
Copy link

maxmandia commented Jul 6, 2022

Does this work with private repos?

@fiizzy
Copy link

fiizzy commented Jul 6, 2022

@maxmandia Yes, it works on private repos.

@SparkRS
Copy link

SparkRS commented Jul 6, 2022

very gud!
image

@aallbrig
Copy link

aallbrig commented Jul 7, 2022

I was able to successfully add these webhooks using the Github CLI. Here is a slimmed down version of code. Hope some find this helpful. Cheers!

# raw copy of discord channel webhook URL
discord_webhook=""
url="${discord_webhook}/github"
# your target github org
org=""
# your target github org repo
repo=""

gh api /repos/"${org}"/"${repo}"/hooks \
  --input - <<< "{
  \"name\": \"web\",
  \"active\": true,
  \"events\": [
    \"*\"
  ],
  \"config\": {
    \"url\": \"${url}\",
    \"content_type\": \"json\"
  }
}"

@Maxime66410
Copy link

Maxime66410 commented Jul 23, 2022

is don't work for me.
image
image

@nitrodynamite18
Copy link

nitrodynamite18 commented Jul 27, 2022

Thank you so much, this worked perfectly!

@Maxime66410
Copy link

Maxime66410 commented Jul 27, 2022

is don't work for me. image image

Correction, so that it works despite the tutorial followed and you still have a 400 error.

Just go to "Recent Deliveries" and resend the request, after that it should work.

@yeste-rge
Copy link

yeste-rge commented Jul 31, 2022

@ishini-peiris
Copy link

ishini-peiris commented Aug 2, 2022

Can we duplicate the same webhook on different repositories?

@ABUCKY0
Copy link

ABUCKY0 commented Aug 6, 2022

Probabaly

Can we duplicate the same webhook on different repositories?

@TerrrorByte
Copy link

TerrrorByte commented Aug 7, 2022

Can we duplicate the same webhook on different repositories?

Webhooks are just a way to deliver messages. You can use the same webhook on multiple different repos, but they will all deliver to the same Discord channel since Webhooks are channel specific afaik.

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