- Use Case
- Log in →
- Static IPs for webhook calls to enable whitelisting
- Responding to API calls using Node-RED Webhook Relay node
- Docker Compose update on Github webhook
- Using Google Firestore for a Golang backend application
- Automated Jenkins builds on GitHub pull request
- Rules-based webhook filtering & routing
- Introducing Cloudflare support for Home Assistant remote access
- Setting up simple, self-hosted & fast CI/CD solution with Drone.io
- Controlling TV with Google Home, IFTTT and Node-RED
- Node-RED OwnTracks location tracking without public IP/MQTT
Auto deploy your Node.js app on push to GitHub in 3 simple steps
Jul 17, 2018, by Karolis Rusenas
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.
First things first, let’s clone the repository:
git clone https://github.com/webhookrelay/webhook-autoupdate
Now, let’s get the tooling.
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:
$ webhook -hooks hooks.json -verbose
Start relay agent:
$ relay forward -b exec http://localhost:9000/webhook
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
While in the repository, install dependencies:
Time to start our node app:
npm run nodemon
That’s it! If you push new changes to the GitHub repository, it will send a webhook that will trigger an update.
When you push to the repository, in
nodemon terminal you should see:
[nodemon] files triggering change check: server.js
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!