-
Find the Discord channel in which you would like to send commits and other updates
-
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!
-
Star
1,048
You must be signed in to star a gist -
Fork
138
You must be signed in to fork a gist
-
-
Save jagrosh/5b1761213e33fc5b54ec7f6379034a22 to your computer and use it in GitHub Desktop.
Gracias.
Anyone know how to setup for private channel?
@StephenHodgson setting up a webhook for a private channel is the same as setting up for a public 😋
I figured out what I did wrong. Needed to add /github
to the end of my webhook url
It's been working great for a long time! 🙂
Question: Does it also work for an entire organization and all repos from that org, or would I have to do it separately?
It's been working great for a long time! 🙂 Question: Does it also work for an entire organization and all repos from that org, or would I have to do it separately?
I tried to do it for the entire organization, github sends the post events out, but nothing happens in the desired channel.
It's been working great for a long time! 🙂 Question: Does it also work for an entire organization and all repos from that org, or would I have to do it separately?
I tried to do it for the entire organization, github sends the post events out, but nothing happens in the desired channel.
Did you check the errors in the Github webhook's recent deliveries area? I accidentally forgot to change it to the content type application/json when I set mine up but it seems to work fine now.
Did you check the errors in the Github webhook's recent deliveries area? I accidentally forgot to change it to the content type application/json when I set mine up but it seems to work fine now.
Yes I did, they all get delivered. It did work, but only new commits got displayed in discord. Nothing else, altho I choose to deliver everything.
Must be an issue on discords side...
Preesh, this is clutch
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\" } }"
where to write this ?
@husamhabib Into a terminal of some kind. You have to have the GitHub CLI installed. If you're on windows you may want to use git bash?
Props to seeing my comment. I've been seeing the chatter but you're the first person to see the CLI stuff..!
It works for a single repo, but when I add it to the organization's webhook, Discord will not post any message.
It works for a single repo, but when I add it to the organization's webhook, Discord will not post any message.
exactly, didn't working for me also... just seeing what is going wrong...
@Vedsaga Actually, after a while, it kind of works for me. My discord server got updates from some repos, but some other repos simply stay silent. I'm not sure what the cause was, but in the meantime, I created several webhooks for different repos.
Yes it dose work after like some time...
Works for me perfectly as of 4/30/23
I tried this, Github shows the requests going out with 204 responses coming back, but nothing appears in discord?
Thanks. I love this feature.
is it possible to ping/mention/notify everyone or certain people using the webhook?
I tried this, Github shows the requests going out with 204 responses coming back, but nothing appears in discord?
Me too, any help anyone?
I tried this, Github shows the requests going out with 204 responses coming back, but nothing appears in discord?
same
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!
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!
I don't know why this is correct, but it worked after deleting the Hook and readding it, it just worked this time.
Can some people smarter than us actually find out what's broken so we can properly document or fix this?
thanks. it works just fine
Is there any way I also get diff data in webhook like in gitlab email notification
Delivery is successful, I get 204 and nothing happens in the channel itself. Something must have gone wrong on Discord's side over last couple of months, what a shame.
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!
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)
Is it possible to send the whole commit message rather then the first few words?
ah, thank you, dude!
please add a red box around the "application/json" part of the image!
How do I make the webhook push text documents of updates?
As with others, the webhook status is green (204), but nothing gets posted to discord.
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?
Got it working:
- delete hook
- create new hook
- add /github at the end,
- select content type to
application/json
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.
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
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").
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.
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?
thank you, worked perfectly