GitHub Webhook Wrapper
The GitHub Webhook Wrapper allows one to maintain a single endpoint (web URL) for all GitHub web hooks, as defined here:
The endpoint is a simple Python CGI script which parses the
the GitHub WebHook, and launches local scripts (if they exist) in the
For example, if your repo were named 'my-awesome-repo' and you committed data to the 'master' branch, the following scripts would be executed (again, only if they exist):
Note that the 'all' script will be called for every commit, to any repo, and any branch.
Installation and Setup
First clone the repository:
$ git clone https://github.com/datafolklabs/github-webhook-wrapper.git
Create a script:
$ touch github-webhook-wrapper/scripts/my-repo $ chmod +x github-webhook-wrapper/scripts/my-repo
Note that the script can be any scripting language you prefer, however it must have a #!shebang line at the top of the file, and must be executable by the web server (i.e. www-root, apache, etc).
examples directory for usage help.
It is not required to use Apache, you simply need to configure whatever web
server to honor '.cgi' scripts. The following is an example config, note that
we obscure the location by adding an MD5 sum to the Alias. This is not
necessary, but will help prevent anyone randomly accessing your hook URL.
Likely the simplest approach is to just restrict who can access the URL.. currently the GitHub sources are
You may consider adding HTTP Basic Authentication, SSL, and adding auth creds
to the URL also, however that is beyond the scope of this example.
AddHandler cgi-script .cgi Alias /5972d04b6930419baf200bcfab8ca71f /path/to/github-webhook-wrapper
And restart Apache. In this example, your URL endpoint would be:
Accessing The Payload Data
payload is passed as a single JSON string argument to every
script. The payload structure is outlined here:
Again, see the examples directory for usage help.