GitHub Actions 工作流程中的 GitHub CLI

问题描述 投票:0回答:1

根据 GitHub Docs,可以在工作流程中使用 GitHub CLI 命令。

我正在尝试通过该存储库中的工作流程以编程方式更新存储库的描述,我找到的唯一解决方案是使用 GitHub CLI:

name: update repo 
on: push
jobs:
  update:
    runs-on: ubuntu-latest
    permissions: write-all
    steps:
      - name: 'Checkout repository'
        uses: actions/checkout@v3

      - name: 'Update repository description'
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        run: gh repo edit --description "test"

但即使使用

permissions: write-all
,我仍然收到错误:

HTTP 403: Resource not accessible by integration
github github-actions github-api github-cli
1个回答
0
投票

根据文档,您需要设置

GH_TOKEN
而不是
GITHUB_TOKEN

例如:

name: Comment when opened
on:
  issues:
    types:
      - opened
jobs:
  comment:
    runs-on: ubuntu-latest
    steps:
      - run: gh issue comment $ISSUE --body "Thank you for opening this issue!"
        env:
          GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
          ISSUE: ${{ github.event.issue.html_url }}

https://docs.github.com/en/actions/using-workflows/using-github-cli-in-workflows

最新问题
© www.soinside.com 2019 - 2025. All rights reserved.