Skip to content

Instantly share code, notes, and snippets.

@jagrosh
Last active November 7, 2024 05:04
Show Gist options
  • Save jagrosh/5b1761213e33fc5b54ec7f6379034a22 to your computer and use it in GitHub Desktop.
Save jagrosh/5b1761213e33fc5b54ec7f6379034a22 to your computer and use it in GitHub Desktop.
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

@Taureon
Copy link

Taureon commented Nov 15, 2023

please add a red box around the "application/json" part of the image!

@KalaniNorman24
Copy link

How do I make the webhook push text documents of updates?

@lukehinds
Copy link

As with others, the webhook status is green (204), but nothing gets posted to discord.

@neoneye
Copy link

neoneye commented Jan 3, 2024

Same issue here. The webhook works when installed on specific repos. However the webhook doesn't work for the organization.

Any idea how to get the webhook work for the organization?

@romanr
Copy link

romanr commented Jan 9, 2024

Got it working:

  1. delete hook
  2. create new hook
  3. add /github at the end,
  4. select content type to application/json

@jhelmink
Copy link

jhelmink commented Jan 11, 2024

There is an official list of supported events from Discord, and no plans to add more;

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

If your event is not on the list, you'll still get a 204, but nothing will come through.

@arbitrarily
Copy link

Got it working:

1. delete hook

2. create new hook

3. add /github at the end,

4. select content type to `application/json`

my man <3 +1

@Benualdo
Copy link

Benualdo commented Mar 4, 2024

Is it possible to send the whole commit message rather then the first few words?

+1

Displaying the name of the target being build would be nice too (I have 4 .yml workflows and they all just display "build success on master").

@Shreyan1
Copy link

I've found a solution, if there's still X's on your webhook, just straight up delete that and create a new one and Make sure to add /github at the discord webhook after you pasted it, hope this helps!

This works. This is the only thing that works.

Add the /github at the end of the Webhook URL.

@haddercone
Copy link

I'm trying to implement the same. But it is more specific. I looked at the GitHub events, they are more generic and not action specific.
E.g I want to receive a message only when a PR is merged or a certain comment is added to the PR.
Is there a way yo to customise this behaviour?

@0PandaDEV
Copy link

Is it possible to disable the pushing feature for private repos?
image

@NicPWNs
Copy link

NicPWNs commented Jun 1, 2024

Hello all past and future!

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! ✅

@OneBigLotus
Copy link

Hello all past and future!

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! ✅

I love that this is a thing! Keep up the good work!_

@The-LukeZ
Copy link

I tried this, Github shows the requests going out with 204 responses coming back, but nothing appears in discord?

I think you haven't add /github at the end :)

@esaruoho
Copy link

worked without a hitch. thanks.

@luisangeldevops
Copy link

any idea why is necesary to add /github at the end?? It work, but...

@haddercone
Copy link

any idea why is necesary to add /github at the end?? It work, but...

Because it helps GitHub to map to a specific endpoint in case of discord.
You can have multiple endpoint on a single domain.

You can achieve this by creating your own endpoints.
E.g. you can create a simple node.js server which has two endpoints /a and /b that do different tasks.

  • Host your node js server on service like render. It will provide you with a domain.
  • Create two different webhooks in GitHub.
  • For each webhook, keep the domain name same but add different endpoints for different GitHub event.

Now you have two webhooks which are mapped to two different GitHub events, but with a single domain name.

@luisangeldevops
Copy link

luisangeldevops commented Jul 17, 2024 via email

@KobeW50
Copy link

KobeW50 commented Aug 8, 2024

is it possible to ping/mention/notify everyone or certain people using the webhook?

Hi. Have you found a way to achieve this?

@The-LukeZ
Copy link

The-LukeZ commented Aug 8, 2024 via email

@KobeW50
Copy link

KobeW50 commented Aug 8, 2024

You can, but not natively. You can either use a bot that can automatically respond with a ping or (a bit trickier) use a bot and a private channel for the Girhub-webhook, so that GitHub sends the message to your private Discord channel and the bot "copies" this message and adds mentions.

Thank you. Do you know of any public bots that can do either of these? (I only tried YAGPDB, but even custom commands doesn't work since it doesn't listen for webhooks)

(Also, a few minutes ago someone shared this with me. It just seems like a bit of a pain to set up)

@mrgoonie
Copy link

mrgoonie commented Aug 8, 2024

@The-LukeZ
Copy link

The-LukeZ commented Aug 8, 2024

You can, but not natively. You can either use a bot that can automatically respond with a ping or (a bit trickier) use a bot and a private channel for the Girhub-webhook, so that GitHub sends the message to your private Discord channel and the bot "copies" this message and adds mentions.

Thank you. Do you know of any public bots that can do either of these? (I only tried YAGPDB, but even custom commands doesn't work since it doesn't listen for webhooks)

(Also, a few minutes ago someone shared this with me. It just seems like a bit of a pain to set up)

I would suggest Sapphire with the new Sticky Message feature for "reply with ping".
It could also be possible to use the Automod feature but I don't know if bot-messages (what a webhook message is) are recognized.
I could make you a custom bot that does this easily if you want (@thelukez)

@KobeW50
Copy link

KobeW50 commented Aug 8, 2024

Thank you for the advice and the offer @The-LukeZ 🙏

I opted to try @mrgoonie 's suggestion, and it is working flawlessly. Thank you

@MichaelJohnsonn
Copy link

MichaelJohnsonn commented Sep 5, 2024

Thank you for sharing this clear and helpful guide on setting up a Discord webhook with GitHub! The step-by-step instructions make it easy to follow, and the added note about keeping the webhook URL private is crucial. It's great to have a straightforward process for integrating GitHub updates directly into Discord channels. This will definitely streamline communication for projects. Appreciate you taking the time to share this! I was searching for a reliable service to buy an assignment online when I came across this article on https://www.linkedin.com/pulse/best-5-services-buy-assignment-online-writingbros-vdmxe. It lists the top services for buying assignments, and I found it incredibly helpful. The recommendations were spot-on, and I decided to use one of the services mentioned. The quality was great, and it was delivered on time. If you’re in the same boat and need help with assignments, this article is worth checking out.

@impanda123
Copy link

Hello I have a problem I cant see the description when i commit to main

@The-LukeZ
Copy link

The-LukeZ commented Sep 6, 2024

Hello I have a problem I cant see the description when i commit to main

Descriptions won't show up. I also noticed this.

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