【问题标题】:Auth error trying to copy repo with Github Actions, take 2尝试使用 Github Actions 复制 repo 的身份验证错误,采取 2
【发布时间】:2020-10-09 08:33:54
【问题描述】:

根据@bk2204 的要求,这是this question 的后续行动。

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

  - 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'

我该如何解决这个问题?我对有问题的两个存储库都有管理员访问权限。

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

【问题讨论】:

    标签: git github github-actions


    【解决方案1】:

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

    • 首先,它使用--depth=1 选项进行浅层克隆。
    • 其次,它只克隆您正在使用的单个 ref。

    这两种方法都可以减少被克隆的数据量,从而可能使运行速度更快。但是,在您的情况下,这有一些问题会阻止它按您想要的方式工作:

    • 首先,您不能从这个浅层克隆推送到新的存储库,因为您的 Actions 存储库可能缺少推送所需的对象(导致“不允许进行浅层更新”)。
    • 其次,您没有克隆任何分支,只克隆了您正在测试的一个分支,因此您隐含地尝试删除所有其他分支。但是,您不允许删除默认分支(在本例中为 master),因此您会收到错误“拒绝删除当前分支”。

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

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

    这将导致一个完整的克隆,但会增加时间,但它允许您将存储库推送到其他地方。

    【讨论】:

      猜你喜欢
      • 2021-01-23
      • 1970-01-01
      • 1970-01-01
      • 2019-10-28
      • 2021-09-07
      • 1970-01-01
      • 2021-05-24
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多