Introducing Continuous Deployment to Heroku

Konstantin Haase,

Heroku is not just a happy Travis Pro customer, but also one of our amazing sponsors!

Are you testing your Heroku application on Travis CI? Then we've got some amazing news for you: Deploying that application after a passing build has just become incredibly easy!

Here is what you need to add to your app's .travis.yml:

deploy:
  provider: heroku
  app: your-app-name # optional if it's the same as your repo name
  api_key: "YOUR API TOKEN"

You should also encrypt your token (at least if you use this on a public repository).

If you have the travis tool installed, try the following:

travis setup heroku

This feature is available immediately on both travis-ci.org and travis-ci.com. See travis-ci/travis-chat for a real world example.

Deploying from Travis CI

Common Scenarios

We have looked into how people currently deploy to Heroku from Travis CI.

Given what people do in their scripts, we tried to make all the common deploy scenarios really easy. Here are a few.

Running migrations after deployment:

deploy:
  provider: heroku
  api_key: ...
  run: "rake db:migrate"

In a Ruby matrix, only deploy from Ruby 1.9.3:

rvm:
  - 1.9.3
  - 2.0.0
deploy:
  provider: heroku
  api_key: ...
  on:
    rvm: 1.9.3

Deploy staging app from staging branch:

deploy:
  provider: heroku
  api_key: ...
  app: my-app-staging
  on: staging

Deploy staging app from master branch and production app from production:

deploy:
  provider: heroku
  api_key: ...
  app:
    master: my-app-staging
    production: my-app-production

For a description of all available options, check out the documentation.

All open source

In good Travis CI tradition, all the code is of course released under MIT license on GitHub. You are more than welcome to take a look and contribute.

More over, since we wanted to make it easy and testable, you can even run our internal tool locally (or lo and behold, use it on your Jenkins setup):

$ gem install dpl
$ dpl --provider=heroku --api-key=`heroku auth:token`

More providers to come

As you might have guessed from the provider option, we are currently working on adding support for other providers besides Heroku.

However, for most other providers, we don't have a lot of real world examples of people already doing or planning to do continuous deployment from Travis CI. So if you do or plan to, you are more than welcome to get in touch.

Sign up for our newsletter

blog comments powered by Disqus