我试图使用GitHub操作在构建工件时自动增加项目的版本,并将新的更改检查回主分支。
工作流使用PAT将提交推送到仅用于此目的的帐户,因此我能够将该用户排除在需要主分支的PR的分支保护规则之外。
因为对于那个分支也有一个必需的状态检查,推失败了。
remote: error: GH006: Protected branch update failed for refs/heads/main.
remote: error: Required status check "build / tests" is expected.
如何让版本提交跳过此检查,同时对所有其他提交执行此检查?
发布于 2022-08-29 13:47:56
我有同样的问题,并尝试了许多不同的潜在解决方案。我唯一能做的就是创建一个具有管理权限的帐户,只允许强制推送该帐户,而不是对管理员强制执行分支保护规则,然后强制推送更改(我使用的是这一行动)。
工作流程基本上如下所示:
jobs:
update-config:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
ref: ${{ github.head_ref }}
token: ${{ secrets.SERVICE_ACCOUNT_GITHUB }}
submodules: true
fetch-depth: 0
## do my update ##
- name: Add and commit change
run: |
git config --local user.email "github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
git commit -m "Bump version" -a
- name: Push changes
uses: ad-m/github-push-action@master
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
branch: ${{ github.head_ref }}
force: true
https://stackoverflow.com/questions/71669640
复制相似问题