Small and highly configurable node server for handling your GitHub Webhooks with support for GitHub/webhook secrets.
Inspired by GitHub Auto Deploy which was written in Python and designed only for pull requests. Gookie is written in Node.js and is just as friendly; but it prints deploy script output and is more configurable. It was designed to solve one or two of the problems we ran into at the eth0 hackathon, such as mentioning in the terminal that a ping event occurred and showing errors during git pull/our deploy script.
To run Gookie as a service/daemon, I recommend checking out forever. It's a really sleek npm package for stopping/starting/running other npm scripts like services.
- Download Gookie or clone the repo (
git clone https://github.com/hoxxep/Gookie
). - Copy
config-example.json
toconfig.json
and then configure the port for your webhook and a github repository.- Also create or configure a logging directory too, and manually create the folder.
- Run
npm install
to install local dependencies. - Run
node Gookie.js
to start the server. - Test your Gookie server is running by visiting your ip:port in a browser.
- Troubleshooting: you may have to open ports if your router/firewall is restricting your chosen port. You can use ngrok as a temporary solution.
- Configure your webhook by visiting your repo settings on GitHub.
- Enter the url of your machine and the port, and specify content type as application/json.
-q
or--quiet
: Reduce the amount of [console] output from Gookie. They still print deploy script output (in case an error occurs).-v
or--verbose
: Show user pushing to which repo and some other extra output [in both gookie.log and console output].
Example config.json
:
{
"port": 8001,
"log": {
"directory": ""
},
"repositories": [
{
"url": "https://github.com/user/repo",
"path": "/home/user/local/git/repo",
"deploy": "git pull",
"secret": ""
}
]
}
port
: if left blank will default to 8001.log
: if removed/directory is left blank will default to the running directory. Note: directory must already exist or an error will be thrown.repository
: any repository options/properties which have been left out default to the following:
{
"url": "https://github.com/user/repo",
"path": "/home/user/local/git/repo",
"deploy": "git pull",
"secret": ""
}
This means if you don't specify a custom deploy
script/command, it will default to git pull
, and the secret
will default to blank. For example, the following repo set up will use git pull
as its deploy script and have no secret.
{
"url": "https://github.com/you/repo",
"path": "/home/user/your/git/repo"
}
Sample output which Gookie outputs to terminal window after the following actions:
- Visited machine URL in browser.
- Pushed to repo hoxxep/Snarl
- This then triggers the
cd "directory" && deploy
command - Which then shows the output of
git pull
- This then triggers the
[02:33:02] Server started on port 8001
[02:35:08] GET request sent from 1.2.3.4
[02:33:15] user hoxxep pushed to https://github.com/hoxxep/Snarl
[02:33:15] cd "/Users/liam/Documents/Projects/Snarl" && git pull
Already up-to-date.
[02:33:16] end of deploy output
- Include support for multiple webhooks on the same repo and different actions for each. This would require unique urls for each hook/event as GitHub doesn't send what the event was in the payload. Will need to look at a neat way to do this in Express.js.
- Daemon/service mode? User can currently do a work around using the npm module
forever
, which might actually be cleaner than implementing daemon/service mode for Gookie on its own?
Created by Liam Gray (@hoxxep). Released under the MIT License.