如何在 travis 中自动升级 gem?

How to auto-upgrade a gem in travis?

我帮助维护 an open source project, Hyrax, which is a rails engine. In order to do QA on new development, we maintain an application that is specifically for QA,Nurax,它应该始终使用 rails 引擎的最新主控进行更新。我已经在 Gemfile 中为 Nurax 指定了 Hyrax 的主分支,如果我 运行 bundle update hyrax 它确实会获得最新的主版本并相应地更新 Gemfile.lock。我还可以让 Nurax 通过 Travis 自动部署。但是,自动部署不会在部署前自动更新到最新的 Hyrax master,这是我真正想要发生的事情。

最好的设置方法是什么?我是否应该让 travis 运行 a bundle update hyrax 并将更改提交给 Nurax master 作为其构建的一部分?我发现了一些关于从 travis 构建提交的主题(例如,this one)。为每个 PR 创建一个新的 Nurax 分支并部署该分支会更好吗?是否有我可以遵循的既定模式?

非常感谢任何建议。

我最终通过 cron 作业解决了这个问题。我在我的 ubuntu 用户的主目录中检查了相关服务器上代码的本地副本。然后我将 ubuntu 用户的 ssh 密钥添加到我自己的 github 帐户,以及用于 capistrano 部署的帐户。然后,我将其设置为每天 运行:

#!/usr/local/bin/ruby

# Get the latest nurax master
# Make a branch with today's date and update hyrax
# Push and deploy that branch

today = Time.now.strftime('%Y-%m-%e-%H-%M')
`cd /home/ubuntu/nurax; git checkout master; git pull; git checkout -b "#{today}"`
`cd /home/ubuntu/nurax; bundle update hyrax`
`cd /home/ubuntu/nurax; git commit -a -m 'Daily update for "#{today}"'; git push --set-upstream origin #{today}`
`cd /home/ubuntu/nurax; BRANCH_NAME="#{today}" cap nurax-dev deploy`
`cd /home/ubuntu/nurax; git checkout master; git branch -d "#{today}"; git push origin --delete "#{today}"`