我正在尝试在 Github 操作中克隆另一个私有(private)存储库。我已经设置了SECRET_USER
和 SECRET_PASSWORD
在 repo 的 secret 中,我正在运行这些操作。在行动中,我正在运行命令
git clone https://$SECRET_USER:$SECRET_PASSWORD@github.com/other-organization/other-repo.git
但得到错误
Cloning into 'other-repo'...
remote: Repository not found.
fatal: Authentication failed for 'https://github.com/other-organization/other-repo.git/'
##[error]Process completed with exit code 128.
在 Github Actions 中,虽然我已经验证用户可以访问
https://github.com/other-organization/other-repo
(这显然不是内部存储库的真实 URL)。
最佳答案
我在 go.yml
中添加了一个 git 配置步骤这样做的伎俩:
- name: Configure git
env:
TOKEN: ${{ secrets.ACCESS_TOKEN }}
run: git config --global url."https://${TOKEN}:x-oauth-basic@github.com/".insteadOf "https://github.com/"
哪里
ACCESS_TOKEN
是 personal access token我添加而不是用户名/密码组合,因为我尝试访问的私有(private)存储库需要启用 SSO 的 token 才能访问它,而不是用户名/密码组合。不幸的是,这在错误消息中并不明显,需要与人们交谈才能了解此信息。
关于git - 在 Github Actions 中克隆私有(private)仓库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60527677/