gpt4 book ai didi

ruby - 如何在 Travis Ruby on Rails 中输入 heroku 凭据

转载 作者:数据小太阳 更新时间:2023-10-29 08:43:39 26 4
gpt4 key购买 nike

我在 Ruby on Rails 网站上工作,我已经用它实现了 Travis CI 并推送到 GitHub,以便在推送到 Heroku 之前测试我的构建。

当 Travis 解析我的 github 源代码时,我收到一个错误,要求我在 Travis 推送到 Heroku 之前输入我的 Heroku Credentials

我想做什么

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 git@heroku.com: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/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com