git - 在 Github Actions 中克隆私有(private)仓库

标签 git github github-actions

我正在尝试在 Github 操作中克隆另一个私有(private)存储库。我已经设置了SECRET_USERSECRET_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_TOKENpersonal access token我添加而不是用户名/密码组合,因为我尝试访问的私有(private)存储库需要启用 SSO 的 token 才能访问它,而不是用户名/密码组合。不幸的是,这在错误消息中并不明显,需要与人们交谈才能了解此信息。

关于git - 在 Github Actions 中克隆私有(private)仓库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60527677/

相关文章:

git - 如何使用 git-bundle 保持开发同步?

git - 为什么特定于 IDE 的项目文件在 Git 中被忽略?

linux - 是否也应该添加 .gitignore 并提交给 git?

macos - 在 brew install 中使用 GitHub 操作缓存

git - Git 是否更改了 .gitignore 中的 "!"前缀行为?

git - 我怎样才能找出是谁 push 了git?

firebase - 无法使用 github 操作将 React Web 应用程序部署到 Firebase 项目

github-actions - 如何将带有空格的字符串值传递给github actions env

firebase - CircleCI 工作流程找不到 Firebase 项目 : Invalid project selection please verify project 'project' exists and you have access

git - 如何从暂存区中删除目录子树?