Using GitHub webhooks
At the most basic level, deployment involves automatically validating, preparing, and releasing new code into production environments. One of the simplest ways to set up a deployment strategy is to trigger releases whenever changes are committed to a Git repository through the use of webhooks. Paraphrasing the GitHub documentation, webhooks provide a way for notifications to be delivered to an external web server whenever certain actions occur on a repository.
In Chapter 2, Installing and Virtualizing Node Servers, we saw a simplified example of this process, where pushing changes to a Heroku instance caused your production build to automatically update. One problem with this simple solution is that no validation was performed—if you pushed bad code, your production server would blindly run bad code. In this section, we'll use GitHub webhooks to create a simple continuous deployment workflow, adding more realistic checks and balances.
We'll build a local development environment...