如何为 github-actions[bot] 授予 .git 权限

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

我已经使用 Blazor WebAssembly 项目在 GitHub 上创建了一个存储库。我的目标是将网站部署到一个单独的分支,以便通过 GitHub Pages 查看它。

我创建了一个 GitHub 操作:

# This is ".github/workflows/gh-pages.yml" file.

name: Deploy to GitHub Pages
on:
  push:
    branches:
      - root
jobs:
  deploy:
    runs-on: ubuntu-latest
    steps:
      # Checkout the code
      - uses: actions/checkout@v4

      # Install .NET Core SDK
      - name: Setup .NET Core
        uses: actions/setup-dotnet@v4
        with:
          dotnet-version: 8.0.x

      # Publish the site
      - name: Publish
        run: dotnet publish MyBlazorApp/MyBlazorApp.sln -c:Release -o:publish -p:GHPages=true

      # Deploy the site
      - name: Deploy
        uses: peaceiris/[email protected]
        with:
          github_token: ${{ secrets.GITHUB_TOKEN }}
          publish_dir: publish/wwwroot
          force_orphan: true

基于 此 NuGet 包

我的问题是:

/usr/bin/git push origin --force gh-pages
remote: Permission to ReusableTemplates/BlazorWASMwGithubPages.git denied to github-actions[bot].
fatal: unable to access 'https://github.com/ReusableTemplates/BlazorWASMwGithubPages.git/': The requested URL returned error: 403
Error: Action failed with "The process '/usr/bin/git' failed with exit code 128"

可以在此处找到该存储库:https://github.com/ReusableTemplates/BlazorWASMwGithubPages

github-actions github-pages blazor-webassembly
1个回答
0
投票

很抱歉回答我自己的问题,但感谢 Stack Overflow 的功能,我了解到问题在于:

Settings -> Action -> General -> Workflow permissions and choose read and write permissions

如果您无法更改它并且您的存储库位于组织中,请在组织的设置中进行更改。

这里找到答案。

© www.soinside.com 2019 - 2024. All rights reserved.