【发布时间】:2021-10-26 14:29:21
【问题描述】:
我在同一个 repo 中有两个 GitHub Actions。我正在尝试从另一个更新一个,但在尝试提交和推送更改时出现以下错误:
! [remote rejected] HEAD -> some-branch (refusing to allow a GitHub App to create or update workflow .github/workflows/the-other-action.yml without workflows permission)
这是我尝试运行的 GH Action 的简化版本:
name: my-action
on:
workflow_dispatch:
schedule:
- cron: "0 9 * * *"
jobs:
components:
runs-on: ubuntu-latest
steps:
- name: Checkout the code
uses: actions/checkout@v2
- name: Update the other Action
run: |
# Do something to .github/workflows/the-other-action.yaml here
- name: Create Pull Request
uses: peter-evans/create-pull-request@v3
with:
token: ${{ secrets.GITHUB_TOKEN }}
branch: some-branch
commit-message: Updated stuff
我想知道如何将workflows 权限授予GITHUB_TOKEN,但不知道如何?
(对于上下文:我每天运行一次此操作,以检查其他操作中使用的工具的新版本是否已发布。如果是,它会创建一个 PR 更新其他操作以使用较新版本而是)
【问题讨论】:
-
您需要在此处使用具有工作流权限的PAT,而不是具有已定义范围的
GITHUB_TOKEN。这是${{ secrets.GITHUB_TOKEN }}你的 PAT 吗?如果是,那就有问题了,因为you can't add secrets with theGITHUB_prefix. -
感谢@GuiFalourd!
GITHUB_TOKEN是默认令牌,而不是 PAT。但我最终使用 PAT 作为解决方法。很高兴知道使用默认令牌是不可能的。 -
太棒了! :D 如果这解决了您的问题,我可以为您的问题添加官方答案吗?
-
@GuiFalourd,当然!
标签: github github-actions