在 Github Actions 中克隆私有存储库

wog*_*and 5 git github github-actions

我正在尝试在 Github actions 中克隆另一个私有仓库。我已经设置SECRET_USERSECRET_PASSWORD在存储库的秘密中运行操作。在操作中我正在运行命令

git clone https://$SECRET_USER:$SECRET_PASSWORD@github.com/other-organization/other-repo.git
Run Code Online (Sandbox Code Playgroud)

但出现错误

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.
Run Code Online (Sandbox Code Playgroud)

在 Github Actions 中,尽管我已经验证用户可以访问https://github.com/other-organization/other-repo(这显然不是内部存储库的真实 URL)。

wog*_*and 9

我添加了一个 git 配置步骤来go.yml实现这个目的:

- name: Configure git
  env:
    TOKEN: ${{ secrets.ACCESS_TOKEN }}
  run: git config --global url."https://${TOKEN}:x-oauth-basic@github.com/".insteadOf "https://github.com/"
Run Code Online (Sandbox Code Playgroud)

其中ACCESS_TOKEN是我添加的个人访问令牌,而不是用户名/密码组合,因为我尝试访问的私有存储库需要启用 SSO 的令牌才能访问它,而不是用户名/密码组合。不幸的是,这一点从错误消息中并不明显,需要与人们交谈才能了解此信息。