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

后端 未结 4 606
醉梦人生
醉梦人生 2020-12-13 01:22

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

4条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-13 01:45

    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=
      • 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
    

提交回复
热议问题