This is a very simple yet convenient tool for catching webhooks from GitHub. Once the call is received, the script executes a command to update the local repository. Starts a constantly running web server that listens for a POST request and automatically creates a pull request in the specified directory.
-d
— directory with github repo to update from server
-p
— port to listen
-s
— [OPTIONAL] a secret string for GitHub webhook identification
-r
— [OPTIONAL] a service name that will be restarted after pull
~$git pull git@github.com:TinKurbatoff/github-webhook-autopull.git
~$cd github-webhook-autopull
~$nohup python3 webhook_listener.py -d /home/user/github_repo -p 9007 [-s <secret>] [-r <some.service>] &
PROFIT!!
To setup a webhook at your repository:
- Navigate to
https://github.com/<github_user_name>/<your_repo>/settings/hooks
- Add a webhook
- Use the following settings (secret string is on you):
- If you are using nGinx (like me):
...
location /webhook/ {
proxy_pass_header Server;
proxy_redirect off;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Scheme $scheme;
include proxy_params;
proxy_pass http://127.0.0.1:9007/;
}
...