Recent Posts
- Auto deploy your Node.js app on push to GitHub in 3 simple steps
- What is a webhook and how to create one?
- Mailgun webhook fan-out
- Web Relay Ingress with Docker for Mac
- How to receive Stripe webhooks on localhost
- DevOps Use Case: Using Github, Webhook Relay and Jenkins
- Keel - automated Kubernetes updates
- Introduction to Webhook Relay
Auto deploy your Node.js app on push to GitHub in 3 simple steps
Jul 17, 2018, by Karolis Rusenas
git github nodejs nodemon reload webhook
Simple use case - deploy your updated Node.js app on a push to a GitHub repository. To achieve this, we will use several tools:
- nodemon - monitor for any changes in your node.js application and automatically restart the server - perfect for development but we will make it perfect for production too :)
- webhook - incoming webhook server which can execute shell commands.
- relay - will allow us to receive webhooks anywhere without exposing them to the internet.

All source code with example Node.js server and configuration can be found here: https://github.com/webhookrelay/webhook-autoupdate.
Preparing tools
First things first, let’s clone the repository:
|
Now, let’s get the tooling.
1. Downloading and starting script executor
Now, install webhook. If you have a working Go environment, you can just do go get github.com/adnanh/webhook, otherwise go to the https://github.com/adnanh/webhook/releases page and grab the one that suits your operating system. If you have a casual Linux machine, you probably want webhook-linux-amd64.tar.gz while MacOS users should choose webhook-darwin-amd64.tar.gz. Download, extract and put it in your PATH or just this repository.
My webhook-autoupdate repository holds hooks.json configuration file which should be supplied to the webhook app. First, edit the hooks JSON file with the correct path to command and working directory. Current one is
|
Update marked fields to something that reflects the path to where you have currently cloned this repository.
Once you did that, start it:
|
2. Download and run relay agent
Start relay agent:
|
Grab that public endpoint and head to your GitHub repository settings page:

Then, add public Webhook Relay endpoint and set “secret” the same one as in your hooks.json (in example file it’s "secret": "verysecret") and content type application/json:

3. Start nodemon
While in the repository, install dependencies:
|
Time to start our node app:
|
That’s it! If you push new changes to the GitHub repository, it will send a webhook that will trigger an update.
Trying it out
When you push to the repository, in nodemon terminal you should see:
|
and in webhook relay bucket you should see request logs:

If you refresh the browser window http://localhost:8080, you will see the new code running.
Interested or working with webhooks? Check out how you can receive webhook on localhost or private networks in our examples collection. Webhook Relay has a free tier for developers!