【问题标题】:Manage hotfixes in Heroku pipeline管理 Heroku 管道中的修补程序
【发布时间】:2019-03-12 06:27:00
【问题描述】:

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

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

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

【问题讨论】:

    标签: git heroku release hotfix


    【解决方案1】:

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

    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
    

    那么:需要基于生产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
    

    就是这样。 :tada:

    【讨论】:

      【解决方案2】:

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

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

      【讨论】:

      • 在哪里可以找到此设置?
      • @AHH 部署 -> 部署方法(选择 Github) -> 手动部署(本页下方)
      【解决方案3】:

      master 是您的部署分支。所以热修复也在master 分支中完成。

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

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

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

      更新

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

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

      开发人员继续在 master 上工作 - 它进入了 staging 但您认为它无法继续进行 master。

      所以你:

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

      【讨论】:

      • 这是一个很好的解决方案,但在这种情况下,我需要设置两个部署:dev 分支到暂存和master 分支到生产。如果我有两个部署,那么我不需要使用 Heroku 的 promotion 功能。文章中有一节(我链接的)关于“为什么不使用 Github Flow?”。 marcgg.com/blog/2016/02/22/git-flow-heroku-pipelines/…
      • 我已经更新了答案。据我了解,关键是从 master 以外的其他分支进行部署。我个人不习惯这种方法
      猜你喜欢
      • 2023-04-09
      • 1970-01-01
      • 1970-01-01
      • 2022-06-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-01-28
      相关资源
      最近更新 更多