Deploy Node Express App to Heroku using Travis CI

Bawantha Rathnayaka
SLIIT FOSS Community
3 min readJan 25, 2021

In this article I will show how to continuously deploy your node express app on Heroku cloud platform using Travis CI.

What is Travis CI?

“Travis CI is a hosted, distributed continuous integration service used to build and test software projects…” — Wikipedia

What will we need?

  1. GitHub Account: To push the code and trigger the Travis CI.
  2. Travis CI Account: To run the tests and build the code for production
  3. Heroku Account: To deploy the app

Steps:

1. Create Travis config file

Create a file named ‘.travis.yml’ in the root folder. Submit this file to GitHub as well

language: node_js
node_js:
- "10"
sudo: false

branches:
only:
- master

cache:
directories:
- node_modules

deploy:
provider: heroku
skip_cleanup: true
keep-history: true
api-key: HEROKU_API_KEY
app: your_heroku_app_name

Read more about this here.

2. Set up Heroku

First you’ll need to create your Heroku app. For that you’ll have to login at Heroku go to your apps page an click on the “New > Create new app” button.

Then you specify your new app name

3. Set up Travis

Go to https://travis-ci.com/ to sign up with your GitHub account. After login, go to ‘Profile’. We see the ‘GitHub App Integration’ section, click ‘Activate’ button and Grant with GitHub authority, choose the repository you want to integrate, click ‘Approve & install’ button.

Keep the default settings for ‘General’ and ‘Auto Cancellation’.

4. Deployment

Make any change to your node app and submit it to Github. Once Travis notice the new submission, it starts to build the app according to the instructions configured in ‘.travis.yml’ file.

If the build is finished successfully, your site is deployed to Heroku 🎉

https://parcel-tracking-system-be.herokuapp.com

--

--

Bawantha Rathnayaka
SLIIT FOSS Community

I write about my experiences as a Software Engineer and the tech I use daily. portfolio - https://bawanthathilan.vercel.app/