我正在使用 Ruby on Rails 网站,我已经用它实现了 Travis CI 并推送到 GitHub,以便在推送到 Heroku 之前测试我的构建。
当 Travis 解析我的 github 源代码时,我收到一条错误,要求我输入我的 Heroku 凭证
,然后 Travis 才能推送到 Heroku。
我想做什么
How do I pass in my heroku credentials to Travis as requested without the >risk of putting it on version control?
这是 Travis 上的构建:https://travis-ci.org/AfolabiOlaoluwa/LawVille/jobs/166099588
.travis.yml
language: ruby
rvm:
- 2.2.4
env:
global:
- secure: {{ I have my travis encrypted key here }}
- secure: {{ I another travis encrypted key here }}
- DB=sqlite
- DB=mysql
- DB=postgresql
- secure: {{ I have another travis encrypted key here }}
deploy:
provider: heroku
api_key:
secure: {{ I have HEROKU API KEY encrypted by travis here }}
script:
- RAILS_ENV=test bundle exec rake db:migrate --trace
- bundle exec rake db:test:prepare
before_script:
- mysql -e 'create database strano_test'
- psql -c 'create database strano_test' -U postgres
after_success:
- gem install heroku
- yes | ruby ./config/initializers/travis_deployer.rb
- git remote add heroku <a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="dcbbb5a89cb4b9aeb3b7a9f2bfb3b1" rel="noreferrer noopener nofollow">[email protected]</a>:lawville.git
- heroku keys:clear
- yes | heroku keys:add
- git push heroku master
最佳答案
上面 @andresk 的答案非常有用,但是仅加密 api-key 对我来说不起作用,正如您从我们的评论/通信中看到的那样。
对我有用的是,从终端内应用程序的根目录运行 setup heroku --org --force
,然后按照提示获取具有正确部署脚本的 Travis 文件。
注意:--force
命令是强制在已经存在的.travis.yml
文件上写入脚本。
响应提示后,我的部署脚本变为:
deploy:
provider: heroku
api_key:
secure: encrypted_key_was_written_here
app: lawville # being app name on heroku which am deploying to.
on:
repo: AfolabiOlaoluwa/LawVille # GitHub Repo
这对我有用。
关于ruby - 如何在 Travis Ruby on Rails 中输入 heroku 凭据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39937430/