尝试使用Github Actions复制存储库时发生验证错误,请执行2 [英] Auth error trying to copy repo with Github Actions, take 2

查看:107
本文介绍了尝试使用Github Actions复制存储库时发生验证错误,请执行2的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是根据@ bk2204的请求此问题的后续操作.

This is a followup to this question, per @bk2204's request.

我正在尝试使用Github Actions将存储库从一个组织镜像到另一个组织.有问题的步骤是:

I'm trying to mirror a repo from one org to another using Github Actions. The step in question is:

  - name: Copy to Cloudyr
    if: runner.os == 'Linux' # && github.ref == 'refs/heads/master'
    env:
      token: "${{ secrets.ghPat }}"
    run: |
      export CLOUDYR_REPO=$(echo $GITHUB_REPOSITORY | sed "s/Azure/cloudyr/")
      git config -l | grep 'http\..*\.extraheader' | cut -d= -f1 | \
        xargs -L1 git config --unset-all
      git push --prune https://token:$token@github.com/${CLOUDYR_REPO}.git +refs/remotes/origin/*:refs/heads/* +refs/tags/*:refs/tags/*

但是,这会导致错误:

Run export CLOUDYR_REPO=$(echo $GITHUB_REPOSITORY | sed "s/Azure/cloudyr/")
To https://github.com/cloudyr/AzureAuth.git
 ! [remote rejected] master (refusing to delete the current branch: refs/heads/master)
 ! [remote rejected] origin/fix-ghaction -> fix-ghaction (shallow update not allowed)
error: failed to push some refs to 'https://github.com/cloudyr/AzureAuth.git'

我该如何解决?我可以同时访问两个有问题的存储库.

How can I fix this? I have admin access to both the repos in question.

失败的日志在这里: https://github.com/Azure/AzureAuth/runs/1228871427?check_suite_focus = true

推荐答案

使用GitHub Actions克隆存储库时,默认情况下,它将以特定方式克隆存储库:

When you clone a repository with GitHub Actions, by default it clones it in a particular way:

  • 首先,它使用--depth=1选项进行浅表克隆.
  • 第二,它仅克隆您正在使用的单个引用.
  • First, it uses the --depth=1 option to make a shallow clone.
  • Second, it clones only the single ref that you're using.

这两种方法都会导致克隆的数据量少得多,这可能会使运行速度大大提高.但是,就您而言,这有一些问题使它无法按您希望的方式工作:

Both of these result in a much smaller amount of data being cloned which makes runs potentially much faster. However, in your case, this has a few problems that prevent it from working the way you want it:

  • 首先,您不能从此浅表克隆推送到新的存储库,因为您的Actions存储库可能缺少进行推送所需的对象(导致不允许进行浅表更新").
  • 第二,除了要测试的单个分支外,您没有克隆任何分支,因此您暗中尝试删除其他所有分支.但是,您不允许删除默认分支(在本例中为master),因此会出现错误拒绝删除当前分支".
  • First, you cannot push from this shallow clone to a new repository because your Actions repository may lack objects needed for the push (resulting in "shallow update not allowed").
  • Second, you haven't cloned any branch but the single one you're testing, so you're implicitly trying to delete every other branch. However, you're not allowed to delete the default branch (in this case, master), so you get the error "refusing to delete the current branch".

您要做的是获取所有分支和标签的所有历史记录,因此您应该传递一个适当的选项:

What you want to do is fetch all history for all branches and tags, so you should pass an appropriate option:

- uses: actions/checkout@v2
  with:
    fetch-depth: 0

这将导致完整的克隆,但会增加时间,但是它将使您可以将存储库推送到其他位置.

That will result in a full clone at the expense of increased time, but it will allow you to push your repository elsewhere.

这篇关于尝试使用Github Actions复制存储库时发生验证错误,请执行2的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆