简体   繁体   English

在合并之前运行 GitHub 状态检查,但不是在每次提交时

[英]Run GitHub Status Check Before Merge But Not On Every Commit

Is it possible to prevent merges of branches on GitHub if CI fails, but not to run CI on every commit?如果 CI 失败,是否可以防止合并 GitHub 上的分支,但不能在每次提交时运行 CI?

Here's a bit more context.这里有更多的上下文。 We have a protected master branch on GitHub and a number of short-lived feature branches.我们在 GitHub 上有一个受保护的master分支和一些短期功能分支。 You can only merge your branch via a pull request and if it's been approved and the CI passes.你只能通过拉取请求合并你的分支,如果它被批准并且 CI 通过。 The CI status is communicated via the GitHub's status checks. CI 状态通过 GitHub 的状态检查传达。 And the CI is run on every commit to that branch.并且 CI 在对该分支的每次提交时运行。

The problem is it takes 30 minutes to run a CI job.问题是运行 CI 作业需要 30 分钟。 Also we have to pay for every minute it runs.此外,我们必须为它运行的每一分钟付费。 Now, of course, there could be ways to make it run faster.现在,当然,可以有办法让它运行得更快。

But is there a way not to run the CI on every commit to a feature branch, but just between the moment the 'Merge' button is pressed and the actual merge occurs?但是有没有办法不在每次提交到功能分支时运行 CI,而是在按下“合并”按钮和实际合并发生之间?

No, it's not possible to do this.不,这是不可能的。

GitHub doesn't even let you access the merge button until the branch is green with the way you have it configured. GitHub 甚至不允许您访问合并按钮,直到分支按照您的配置方式变为绿色。 Furthermore, the way CI tools work with GitHub is by getting notification of pushes to a pull request.此外,CI 工具与 GitHub 一起工作的方式是获取推送到拉取请求的通知。 Therefore, the only time your CI system gets notified is when a PR is opened or when new data gets pushed to it.因此,只有在打开 PR 或向其推送新数据时,您的 CI 系统才会收到通知。

It may be possible to configure your CI system not to run automatically and to store the data sent to it and then run when a button in their UI is pressed.可以将 CI 系统配置为不自动运行并存储发送给它的数据,然后在用户界面中的按钮被按下时运行。 If it came back green, then 30 minutes later you could press the merge button.如果它变回绿色,则 30 分钟后您可以按下合并按钮。 That would be the closest thing to what you want to do, but that depends on your particular CI provider, so you'd have to inquire about it with them.这将是最接近您想要做的事情,但这取决于您的特定 CI 提供者,因此您必须向他们询问。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM