Rails 5 - Circle CI - Heroku - 部署后运行迁移

时间:2017-05-09 19:19:50

标签: ruby-on-rails heroku circleci

部署到Heroku后,我希望迁移在部署后运行。在circle.yml -

中尝试了以下配置
deployment:
  staging:
    branch: <branch_name>
    heroku:
      appname: <appname
    commands:
      - heroku run rake db:migrate --app alldaydr:
        timeout: 400
      - bundle exec rake swagger:docs
    commands:
      - git push git@heroku.com:<appname> $CIRCLE_SHA1:master
      - heroku run rake db:migrate --app <appname>

它成功部署但不运行迁移。任何帮助/想法?

1 个答案:

答案 0 :(得分:0)

以下是我的配置。我只有一条commands指令并在推送到Heroku之后运行rake迁移。您还可以从CircleCI上的部署日志中获得一些提示。

deployment:
  production:
    branch: <branch-name>
    commands:
      - "[[ ! -s \"$(git rev-parse --git-dir)/shallow\" ]] || git fetch --unshallow"
      - git push git@heroku.com:<appname> $CIRCLE_SHA1:refs/heads/master
      - heroku run rake db:migrate --app <appname>:
          timeout: 400 # if your deploys take a long time
      - heroku run rake swagger:docs --app <appname>

有关更多信息,请参阅CircleCI's documentation

相关问题