我创建了一个GitHub操作,以创建一个新版本并将其发布给我们的JS回购。看起来与此类似
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
with:
node-version: 12.18.3
registry-url: https://npm.pkg.github.com/
scope: '<redacted>'
- name: Install Dependencies
run: npm ci
- name: Build
run: npm run build
- name: Bump Version & Push
run: |
git config --local user.email "<redacted>"
git config --local user.name "<redacted>"
npm version patch
git push https://${{ secrets.KEY }}@github.com/<redacted> HEAD:master --follow-tags
我正在使用的KEY是我从我的帐户创建的个人访问令牌。我已经设置了存储库,以便可以推送访问master分支。当我尝试使用访问令牌从机器上执行push命令时,它可以正常工作。但是,每次我在GitHub Action中看到这一点
remote: error: GH006: Protected branch update failed for refs/heads/master.
remote: error: You're not authorized to push to this branch. Visit https://docs.github.com/articles/about-protected-branches/ for more information.
我一直在绞尽脑汁,试图弄清楚这一点,但我有很多想法。如果我删除分支保护,则此操作正常。
答案 0 :(得分:2)
我认为这是因为actions/checkout
如何保持身份验证。它存储在extraheader
配置选项中,该选项优先于您手动设置的凭据。
尝试不保留身份验证:
- uses: actions/checkout@v2
with:
persist-credentials: false
或者:
- uses: actions/checkout@v2
with:
token: ${{ secrets.KEY }}
我之所以知道这一点,是因为我过去曾经使用过own issue来覆盖此配置选项。
答案 1 :(得分:0)
只需将n拖放到“添加文件”按钮下