In this example, we are deploying to Heroku, but we're going run tests on TravisCI before deploying to Heroku.
Pre-requisites:
- a travisCI account
- Generic heroku deployment pre-requisites
- an
npm test
command inpackage.json
Steps:
- Visit https://travis-ci.org and add repo as a travis project
- Launch a terminal and change current directory to home directory of your project
- create an empty
.travis.yml
file in your project directory:touch .travis.yml
- add the following configuration to
.travis.yml
:
language: node_js
node_js:
- "9"
cache:
directories:
- node_modules
script:
- npm test
deploy:
provider: heroku
app: swift-waters-95000 # replace this with the name of your heroku app
on:
repo: davified/temp_heroku_travis # replace this with your_github_username/your_repo
- Generate secure api_key in
.travis.yml
:travis encrypt $(heroku auth:token) --add deploy.api_key
git add
,git commit
andgit push
.travis.yml
- Go to https://dashboard.heroku.com/ to complete the Heroku-Github integration
- Lastly, add any add-ons services (e.g. mlab) that you're using on heroku and add the necessary config vars (if any) on the heroku dashboard