在 github 工作流程中出现错误:远程:重复标头:“授权”

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

我在工作流程中使用自托管运行器。由于某种原因,在结账步骤中出现以下错误

错误:

Fetching the repository
  /usr/bin/git -c protocol.version=2 fetch --prune --progress --no-recurse-submodules --unshallow origin +refs/heads/*:refs/remotes/origin/* +refs/tags/*:refs/tags/*
  remote: Duplicate header: "Authorization"
  Error: fatal: unable to access 'https://github.com/og/snow/': The requested URL returned error: 400
  The process '/usr/bin/git' failed with exit code 128

工作流程代码:

 determine_scope:
    runs-on: self-hosted
    outputs:
      prev_sha: ${{ steps.prev_sha_fetch.outputs.prev_sha }}
      deploy: ${{ steps.scope_check.outputs.deploy }}
    steps:
      - name: Checkout Repo
        uses: actions/checkout@v3
        with:
          fetch-depth: 0  # Fetch all commit history
          persist-credentials: false

      - name: Fetch Prev SHA
        id: prev_sha_fetch
        run: |
          prev_sha=$(curl -L -s \
            -H "Accept: application/vnd.github+json" \
            -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
            -H "X-GitHub-Api-Version: 2022-11-28" \
            "https://api.github.com/repos/${{ github.repository }}/actions/workflows/${{ inputs.workflow_name }}/runs?branch=main&status=success&per_page=1" \
            | jq -r '.workflow_runs[0].head_sha'
          )
          echo "Current SHA: ${{ github.sha }}"
          echo "Previous SHA: $prev_sha"
          
          if [[ "$prev_sha" != "null" && -n "$prev_sha" ]]; then
            echo "::notice ::Triggered partial deployment"
          else
            echo "::notice ::Triggered full deployment"
            prev_sha='null'
          fi
          
          echo "prev_sha=$prev_sha" >> $GITHUB_OUTPUT

尝试了不同的结帐版本,还使用了 persist-credentials: false,没有任何效果。

git github github-actions cicd
1个回答
0
投票

您的存储库必须有一个 git 配置文件,除了 auth 标头中的 GitHub 工作流设置 GITHUB_TOKEN 之外,还可以设置 git 凭据。

您可能可以在工作流程的“身份验证”部分下的“设置作业”步骤中看到此内容。

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