Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to restrict Github Post-Receive WebHook to master branch only

Tags:

github

Question is pretty much self explanatory. I want that the webhook will be triggered on commits to master branch only, I might be wrong, but from my experience right now it seems to be triggered on commit to every branch.

like image 449
Michael Avatar asked Dec 26 '13 21:12

Michael


People also ask

How do you create a Webhook secret?

Adding a deploy secretSelect Configuration in the project settings panel. Scroll down to the Webhook Deploy Secret section, then click Set Webhook Secret. Looker will automatically generate a secret token. You can use this automatically generated secret, or you can type in your own secret token.


1 Answers

Considering that you don't have much control over a GitHub post-receive hook, it seems easier to filter the JSON message representing the payload of said hook.

You can check the value of the "ref" element

"ref":"refs/heads/master",

Any part of the JSON message which don't include the expected ref could be ignored by your listener.

like image 85
VonC Avatar answered Oct 20 '22 06:10

VonC