Github工作流/操作提交到存储库返回403

ryoqjall  于 2023-01-07  发布在  Git
关注(0)|答案(1)|浏览(155)

我有一个Github工作流文件,我在其中提升了python包(setup.py)的版本,然后我想将更改推送到工作流运行所在的存储库中。但是我得到403,没有授予回访问权限

build-package:
    permissions:
      contents: read
      id-token: write
      pull-requests: write
      issues: write
      repository-projects: write
      deployments: write
      packages: write
      

    runs-on: ubuntu-latest
    needs: test
    steps:
      - uses: actions/checkout@v3
      """ STEPS BETWEEN""""
      
      
      - name: Set up Python 3.10
        uses: actions/setup-python@v1
        with:
          python-version: "3.10"
      - name: Install dependencies
        run: |
          python -m pip install --upgrade pip
          python -m pip install setuptools
          python -m pip install wheel
          python -m pip install bump
      - name: Bump version
        run: |
          bump --patch
          # add step that commits the setup.py and skips the ci/cd
      - name: Commit version
        run: |
          git config --global user.email "github-actions[bot]@users.noreply.github.com"
          git config --global user.name "bot"
          git commit -m "Bump version" setup.py
          git push

      - name: Build package
        run: |
          python setup.py sdist bdist_wheel

它回来了

fatal: unable to access 'https://github.com/repository/': The requested URL returned error: 403
ssm49v7z

ssm49v7z1#

git提交和推送本身就很好,您只是将用于推送的GITHUB_TOKEN的作用域限制为read-only
转换此:

permissions:
      contents: read

对此:

permissions:
      contents: write

请注意,这将只允许推送正常的代码更改,而不允许推送工作流文件(具有额外安全范围的文件)。

相关问题