Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to run post-receive hook on GitHub

Tags:

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.

like image 474
Higor Ramos Avatar asked Sep 27 '13 01:09

Higor Ramos


People also ask

How do you run a pre-commit hook?

If you want to manually run all pre-commit hooks on a repository, run pre-commit run --all-files . To run individual hooks use pre-commit run <hook_id> . The first time pre-commit runs on a file it will automatically download, install, and run the hook. Note that running a hook for the first time may be slow.

How do I get Git hooks?

To install the hook, you can either create a symlink to it in . git/hooks , or you can simply copy and paste it into the . git/hooks directory whenever the hook is updated. As an alternative, Git also provides a Template Directory mechanism that makes it easier to install hooks automatically.


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.

like image 129
VonC Avatar answered Oct 04 '22 02:10

VonC