how to run a post-receive hook in GitHub?. I know that there is the web-one but I want to write a custom script and do not want to receive a post from github.
-
1Well you can't run your own code on the Github servers. That is why Github provides the option to receive notifications by HTTP POST. – Greg Hewgill Sep 27 '13 at 03:34
-
I suppose if it did Circle CI and such wouldn't exist? – Costa Michailidis Mar 19 '17 at 05:52
1 Answers
The post-receive hook of Github are actually only "WebHooks", to communicate with a web server whenever the repository is pushed to.
For security reason, you cannot run anything on the GitHub server side.
When a push is made to your repository, we'll POST to your URL with a payload of JSON-encoded data about the push and the commits it contained.
You can use Requestbin to test your webhooks.
(check that the JSON actually comes from GitHub though)
Note: since late 2018, you can run actions on GitHub server-side, with GitHub Actions.
Actions are triggered by GitHub platform events directly in a repo and run on-demand workflows as autoscaled containers in response.
With GitHub Actions you can automate your workflow from idea to production.
See examples with sdras/awesome-actions
.
Other examples, provided by Encryptex in the comments:
"How to setup continuous deployment of a website on a VPS using GitHub Actions" from Igwaneza Bruce.

- 1,262,500
- 529
- 4,410
- 5,250
-
1Maybe this is useful: https://dev.to/knowbee/how-to-setup-continuous-deployment-of-a-website-on-a-vps-using-github-actions-54im – EncryptEx Mar 03 '23 at 11:48
-
@EncryptEx Good example indeed. I have included it in the answer for more visibility. – VonC Mar 03 '23 at 11:57