Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Trigger a webhook every time something merge into master - GitHub Webhooks

I not sure exactly how this will work, but I am looking to run a bash script that updates master every time something merges into master through Github. Is there a GitHub webhook that could be triggered on a PR merge? Also, I am not sure how would I update master through this web hook? Or any other suggestions how this could be done? I don't know if I am heading in the right direction.

By updating master, I meant, pull everything from master. Run a bash script that makes few changes and push new changes back to master.

like image 649
Hafiz Temuri Avatar asked Jul 31 '18 17:07

Hafiz Temuri


1 Answers

The GitHub webhook push event would be useful in this case. You would need an server/application to listen for the hook, e.g. a node.js/php server, or CI services.

In your server, check the webhook payload for ref === refs/head/master i.e.master branch, or other conditions you see fit. Then to modify the repo's master branch, run a local git command or call GitHub API with proper credentials.

P.S. Updating the master branch with this service would also trigger a webhook event, so maybe you want to check for pusher too in this case.

like image 143
William Chong Avatar answered Sep 20 '22 00:09

William Chong