Skip to content

Instantly share code, notes, and snippets.

@jagrosh
Last active June 15, 2024 06:02
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

@mrgoonie
Copy link

mrgoonie commented Oct 4, 2023

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! If you already add failed webhook before, you also need to delete it and add it again with /github at the end of the URL (another note is Content-Type must be application/json)

Cheers!

@joshytaco
Copy link

joshytaco commented Oct 8, 2023

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!

What do you mean by this? Does the webhook not work if there are Xs in the webhook url? What an odd bug.

I'm getting the same issue as others in this thread, created a webhook url to post to a discord channel and GitHub says that the request was sent with a 204 response, but nothing is appearing in the discord channel.

EDIT: fwiw, the test deploys on github's end don't work. you'll need to test with a real action in the repo (push to branch, etc)

@Seavens
Copy link

Seavens commented Oct 12, 2023

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

@Milkywayrules
Copy link

ah, thank you, dude!

@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?

@creatorrr
Copy link

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

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