Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to deploy an rails app on heroku from travis-ci?

There is any way to deploy a heroku rails app after a travis-ci success build?

like image 345
danielgatis Avatar asked Apr 19 '12 19:04

danielgatis


2 Answers

Travis CI now has built-in support for deploying to Heroku: http://about.travis-ci.org/blog/2013-07-09-introducing-continuous-deployment-to-heroku/

like image 138
Konstantin Haase Avatar answered Sep 30 '22 10:09

Konstantin Haase


I just implemented this case with an application of mine. It's actually not that hard to do, but it requires some steps:

  1. You need your heroku API key
  2. See this gist for an example .travis.yml and get the travis_deployer.rb script
  3. Then install the travis gem, see the answer to another question on how to secure your API key.
    • If you don't care about it, just use the example from gist above.
    • Run travis encrypt your_username/your_repo HEROKU_API_KEY=<your key here>
    • Copy the result in your .travis.yml in the env -> global section

The travis_deployer.rb file takes care of the ssh keys and the remote branch for heroku.

If you've performed all these steps you .travis.yml might look like this:

env:
  global:
    - secure: "1u21hjnmHjkghduUIJhhs76saljlkajdlfhGhgdJgfaVtgasfLLmNBnb87dad="

after_success:
  - gem install heroku
  - yes | ruby travis_deployer.rb
  - heroku keys:clear
  - yes | heroku keys:add
  - git push heroku master
like image 42
Odi Avatar answered Sep 30 '22 11:09

Odi