管理 Heroku 管道中的修补程序

Manage hotfixes in Heroku pipeline

我有一个简单的 Heroku 部署管道(查看应用程序 -> 开发 -> 暂存 -> 生产)。 如果我将某些内容推送到 master,那么它将触发 CI(codeship),如果测试 运行 成功,Codeship 会将更改部署到 development Heroku 应用程序。很简单。

但是我们如何管理修补程序?如果我们出于任何原因无法将当前 master 部署到生产环境,会发生什么情况。

我刚读到一篇 article,其中说我们应该处理带有 git 标签的修补程序。这是管理修补程序的唯一方法吗?我们可以不使用 git 标签来处理这些吗?

master 是你的部署分支。所以修补程序也在 master 分支中完成。

我假设您也有一个开发分支。因此,如果您有正在进行的工作,您将继续在开发分支上进行,而不是将其合并到 master.

如果 master 损坏 - 您必须修复它(因此是修补程序)。您解决问题,将其推送到 master,然后继续部署周期。

然后您还应该将修补程序挑选回您的开发分支。

更新

如果您希望坚持使用单个 master 分支,那么我看不到使用修补程序分支的解决方法。

您不必每次都标记一个。但关键是要知道哪个版本是当前生产插槽中的最后一个稳定版本。

开发人员继续致力于 master - 它进入了 staging,但您认为它无法继续掌握。

所以你:

  • 根据当前版本创建一个新分支 - 这是修补程序分支。
  • 创建修复程序
  • 部署它
  • 合并到 master

对于仍然对此感到困惑的任何人,Heroku Pipelines 允许您从任何分支部署您的生产应用程序:

您可以通过从当前部署到您的生产应用程序的代码手动创建一个分支并挑选您需要的修复程序来发布修补程序。

首先,我们需要准备遥控器:

git remote -v
# should contain the production remote with whatever name (better producation for sure), for example:
#
# production    https://git.heroku.com/your-repo-prod.git (fetch)
# production    https://git.heroku.com/your-repo-prod.git (push)
# staging   https://git.heroku.com/your-repo-staging.git (fetch)
# staging   https://git.heroku.com/your-repo-staging.git (push)

# if not, use this to add:
git remote add production https://git.heroku.com/your-repo.git

然后:您需要最新的远程分支:

git fetch production

然后:需要根据production Heroku-branch创建新的分支:

git checkout -b hotfix/TICKET -t production/master

# where 'hotfix/TICKET' is your preferred branch name

然后您需要应用修补程序更改,例如:

1) 手动:

# -> do something with codebase
git add .
git commit -m "hotfix: bla..."

2) 通过 cherry-pick 特定提交:

git cherry-pick COMMIT_HASH

# or use this, if you need to cherry-pick the 'merge-commit':
git cherry-pick -m 1 MERGE_HASH

现在您需要推送更改:

git push production hotfix/TICKET:master
# where 'hotfix/TICKET' is your preferred branch name

就是这样。 :多田:[=1​​6=]