描述错误
在 CI 环境中运行 auto 时,例如 Github Actions,当打开 master 分支保护时, auto shipit
将失败。 有什么办法,也许是通过以某种方式设置权限,在不禁用分支保护的情况下克服这个问题?
再现
使用以下 Github Action 工作流并将 master 设置为受保护分支将导致推送尝试失败并显示以下错误消息:
Error: Running command 'git' with args [push, --follow-tags, --set-upstream, origin, master] failed
remote: error: GH006: Protected branch update failed for refs/heads/master.
remote: error: At least 1 approving review is required by reviewers with write access.
Github 操作工作流
name: Release
on:
push:
branches:
- master
jobs:
release:
runs-on: ubuntu-latest
if: "!contains(github.event.head_commit.message, 'ci skip') && !contains(github.event.head_commit.message, 'skip ci')"
steps:
- uses: actions/checkout<strong i="15">@v1</strong>
- name: Prepare repository
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
git checkout ${GITHUB_REF:11} --
git remote rm origin
git remote add origin "https://x-access-token:[email protected]/<owner>/<repository>"
git fetch origin --tags
git branch --set-upstream-to origin/${GITHUB_REF:11} ${GITHUB_REF:11}
- name: Use Node.js 12.x
uses: actions/setup-node<strong i="16">@v1</strong>
with:
node-version: 12.x
- name: Cache node modules
uses: actions/cache<strong i="17">@v1</strong>
with:
path: node_modules
key: yarn-deps-${{ hashFiles('yarn.lock') }}
restore-keys: |
yarn-deps-${{ hashFiles('yarn.lock') }}
- name: Create Release
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
run: |
yarn install --frozen-lockfile
yarn build
yarn auto shipit
secrets.GITHUB_TOKEN
实际上没有对您的存储库的写访问权限。 您需要从具有写访问权限的用户创建令牌。
我认为这就是问题所在。 如果这有效,请回复评论,我会在文档中添加注释。 (或者如果你想做公关我会合并它)
不幸的是,这并没有解决问题。 似乎GITHUB_TOKEN
是自动创建的,应该具有正确的权限。 但是我使用自定义令牌进行了尝试,该令牌也不起作用。
为 auto-config-hipstersmoothie 打开分支保护并切换到 GITHUB_TOKEN。
当您说打开分支保护时 - 这包括什么? Allow force pushes
禁用?
编辑:第二个链接应该是这样的: https :
第二个链接应该是这个
是的,对不起!
允许强制推送禁用
auto 不会强制推送,所以这应该不是问题。这是我配置的
@bbrinx 有任何更新吗? 如果没有可复制的示例,可能很快就会关闭
@hipstersmoothie我添加了一个具有所有权限的令牌并且它起作用了! 我第一次尝试时似乎没有设置正确的权限。 谢谢!
惊人的!
最有用的评论
@hipstersmoothie我添加了一个具有所有权限的令牌并且它起作用了! 我第一次尝试时似乎没有设置正确的权限。 谢谢!