绕过 GitHub 中所需的状态检查

Sil*_*aze 13 github github-actions

我正在尝试使用 GitHub Actions 在构建工件时自动增加项目的版本,并将新更改签回主分支。

工作流程使用仅用于此目的的帐户的 PAT 推送提交,因此我能够将该用户从需要主分支 PR 的分支保护规则中排除。

因为该分支还需要进行状态检查,所以推送失败并显示

remote: error: GH006: Protected branch update failed for refs/heads/main.        
remote: error: Required status check "build / tests" is expected.   
Run Code Online (Sandbox Code Playgroud)

如何让版本提交跳过此检查,同时对所有其他提交强制执行此检查?

mig*_*iam 5

2023-09-01

最近的功能,规则集,提供了更多的控制,例如允许指定的参与者绕过状态检查要求。


小智 0

几天前我遇到了同样的问题。如果您standard-version在中使用 then ,package.json您可以执行以下操作:

"standard-version": {
    "releaseCommitMessageFormat": "chore(release): {{currentTag}}\n[ci skip]",
  },
Run Code Online (Sandbox Code Playgroud)

在 Github 工作流程中,build / tests您可以添加一个条件来跳过测试,以防推送被标记为[ci skip]如下:

if: "!contains(github.event.head_commit.message, '[ci skip]')"
Run Code Online (Sandbox Code Playgroud)

参考