node package manager
Love JavaScript? Your insights can make it even better. Take the 2017 JavaScript Ecosystem Survey »


Simple GitHub Webhook

A simple, Node.js based webhook meant for shell-script based deployment!


Step 1. Installing

Let's say you just want to use this for fast and easy deployment for your web project. First thing's first clone this repository and install the required dependencies.

git clone
cd simple-github-webhook
npm install

While you're at it, you should also edit the script to be more suitable for your deployment needs.

Step 2. Starting it up

The webhook takes in the following four parameters, passed in through environment variables:

Variable Meaning Default
SECRET The GitHub secret for authentication None (required!)
HOOK_PATH The sub-path that the script runs under /
PORT The port the script runs under 8080
BRANCH The git branch that the webhook is listening for commits master

So for example, if you'd like to listen to changes to the feature-foo branch on port 1337 and run a script every time someone commits to the branch in question, you'd start the webhook by:

PORT=1337 SECRET='My secret secret' BRANCH='feature-foo' npm start


GitHub webhook running at:
Listening for commits to branch refs/heads/feature-foo

Step 2. Setting up your repository on GitHub

First, go to your repository's setting page, click on "Webhooks and services", and click on the button on the top right, labeled "Add webhook"

GitHub will then prompt you for your password.

Next, fill in the correct URL, path and secret that you specified and received while starting the webhook.

That should be enough to get your webhook up and running! Feel free to make a test commit or two to the branch you specified at the start to test it.

Running deployment now...
Deployment finished!


MIT © Matti Jokitulppo

npm version npm downloads