Webhooks: how to


#1

Hi,
I have to create a webhooks repo for my repository.
I’ve read the documentation but was stilla unable to create one.
I need it because another plattform (readthedoc) ask me.
Can someone sudgest me ho can I create a valid URL for that?

TIA
Renato


#2

To setup a github webhook first goto your github.com repository
Across the top of page are various tabs :

Code Issues Pull requests Projects Wiki Insights Settings

get into Settings -> Webhooks -> Add webhook

now under Payload URL you will want something like

https://example.com/hooks/loudthink_webhook 

Content type

application/json

Secret

  just type in a secret you will need this later

Which events would you like to trigger this webhook ?

   since I want my webhook to get triggered whenever anyone issues a `git push` I choose     `Just the push event`

SAVE now comes the hard part — its up to you to create a server on your own machine which is your webhook server — I did some research and decided to use this https://github.com/adnanh/webhook which I installed and now execute as a daemon on my machine which actively subscribes to above github repo webhook publish of any git push event … this webhook server listens to above mentioned Payload URL … when someone issues git push then github will publish traffic which is subscribed and listened to by your webhook server … then your webhook server launches your own process to perform some action upon every such git push … Done ~ enjoy


#3

sorry, I’'m still unable to do that. you mean that I have to install a server and give the URL of my server?
It does not exist a public server that I can access?

Renato


#4

Can you explain your data flow ? Essentially step one is someone executes the command

git push 

on a branch of your repo … that action will get picked up by github.com and then github itself will then publish out to

Payload URL  (as described above)

some webhook server owned NOT by github must have been running and actively listening to that

Payload URL

at this point the webhook server can do something now knowing a git push event just happened … typically webhook server will now launch a process to do something with the freshly changed repo like issue git pull then rebuild the code

To answer your question I do not know … you mentioned another team (readthedoc) … perhaps they have a webhook server … ask them for its Payload URL and put that value into above field in your repo settings I described above … it does not matter who owns the webhook server … github.com itself does not give people such a server teams must setup a webhook server themselves


#5

ok, thank you for the info you give me.
Now, I think the problema is to obtain an URl. If GitHub does not give this service, I’m wondering if someone knows who can give me that service

Renato


#6

I have no relation with https://github.com/adnanh/webhook other than being someone who has downloaded that repo and installed its code which gives me a webhook which I execute on my own server … works fine and is fairly easy to install and its totally free

… as mentioned in above repo link is a paid service where they provide a webhook server which runs on their machine which listens to your own git push on your repo then executes your scripts on your server … just read the top portion of the github description for a link to that paid service … looks to be $2 per month with a free trial

… you will still need to have your own server to execute the scripts which get launched from their webhook server it just offloads having to run a webhook daemon on your server