Github 操作:在私有存储库中找不到默认分支

时间:2021-06-12 13:38:00

标签: github build github-actions

我有一个私人存储库,我需要在另一个私人存储库中检出和使用。 所以在工作流程中我这样做:

  - name: Checkout small private repo
    uses: actions/checkout@v2
    with:
      repository: name/smallprivaterepo         
      path: build/

我尝试使用 ${{ secrets.REPO_ACCESS_TOKEN }}env: GITHUB_TOKEN 没有成功。

Determining the default branch
  Retrieving the default branch name
  Not Found
  Waiting 18 seconds before trying again
  Retrieving the default branch name
  Not Found
  Waiting 13 seconds before trying again
  Retrieving the default branch name
  Error: Not Found

我试图获取的私有存储库的默认分支是 master。将 ref: master 添加到 .yml 时,我得到:

  /usr/bin/git -c protocol.version=2 fetch --no-tags --prune --progress --no-recurse-submodules --depth=1 origin +refs/heads/master*:refs/remotes/origin/master* +refs/tags/master*:refs/tags/master*
  Error: fatal: could not read Username for 'https://github.com': terminal prompts disabled
  The process '/usr/bin/git' failed with exit code 128
  Waiting 12 seconds before trying again

1 个答案:

答案 0 :(得分:0)

好的,我成功了,但我不知道这是否是安全的方法。

所以我的开发者设置中已经有了 PAT: Google Authenticator manifest on GitHub

然后我将一个名为 MYPAT 的秘密添加到试图签出私有存储库的存储库中。该秘密包含 PAT 令牌!

然后只将其添加到 yml 中:

token: ${{ secrets.MYPAT }}

所以PAT令牌实际上在github中保存了两次。