Skip to content

Python 3 tiny web-server to make git pull request if receiving a GitHub webhook call

Notifications You must be signed in to change notification settings

TinKurbatoff/github-webhook-autopull

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

24 Commits
 
 
 
 

Repository files navigation

image

Simple HTTP GitHub webhook listener

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:

  1. Navigate to

https://github.com/<github_user_name>/<your_repo>/settings/hooks

  1. Add a webhook

image

  1. Use the following settings (secret string is on you):

image

  1. 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/;    
        }
...

About

Python 3 tiny web-server to make git pull request if receiving a GitHub webhook call

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages