Deploying a Node application to Heroku, part 3
How to set up continuous deployment from GitHub
|Cesare Ferrari||Dec 4, 2019|
Now that our application is ready to be deployed to Heroku we can make things easy for us by setting up a system of continuous deployment from GitHub.
This means that, after a simple set up, we can just push our code to our Git repository on GitHub and have Heroku automatically detect code changes, grab the latest version of our app, and deploy it to production, without us having to take care of this process manually.
After we update our app, all we have to do is commit our changes, push the code to GitHub, and Heroku will take care of the rest.
As soon as our code is received by GitHub, it will trigger a new automatic deploy, and the production server will be restarted immediately, without our involvement.
Setting up continuous deployment on Heroku
We first need to sign up for an Heroku account and log in.
In our Heroku dashboard, at the top, we click the button to create a new app.
Next we give our app a unique name (names need to be unique across the Heroku platform), and when the application is created we go to the
Deployment method, we select GitHub. If it's the first time we select this option it will prompt prompt us for permission to connect to our GitHub account.
Once the GitHub account is connected, we need to pick the repository for the application.
Since our repository may have different branches, Heroku will also ask which branch to connect, under
It's convenient to be able to choose the branch to deploy since often we may have different different versions of our application, like development, staging, or production, on different branches.
Once we have chosen the branch, we select
Enable Automatic Deploys.
From now on, when we push to GitHub, Heroku will perform an automatic deploy.
These steps set up the automatic deploy for us, but automatic deploy will be triggered only when we push new code to GitHub.
So, the very first time we set up a new application, we should make a manual deploy, which can be done in the
Manual Deploy section in the Heroku dashboard.
Did you like this article? Share it with your friends.
I write daily about front-end and back-end web technologies.
You can receive all my articles in your inbox by subscribing to my newsletter. Just click the button below. No spam, just good, useful content. Guaranteed!