如何在 Github Actions with Cargo 中下载另一个私有仓库?
How to download another private repository in Github Actions with Cargo?
问题
我有一个私有 Rust 项目 (A),它依赖于另一个私有 Rust 项目 (B)。在我的本地机器上,它可以工作,因为我登录到 git。我不确定如何在 Github 操作中登录 git。我不确定是否需要。我读了很多关于 SSH 和 HTTPS 的东西,以至于我忘记了我必须做什么。
我看到了 https://github.com/webfactory/ssh-agent, https://github.com/fusion-engineering/setup-git-credentials 和其他一些操作,但我只是在猜测我需要做的事情,但我无法让它发挥作用。
设置
这是我在项目 A 中的 Cargo.toml 文件:
...
[dependencies]
b = { git = "https://github.com/me/b.git" }
这在 Github 操作中失败,因为 Github 操作无法在没有某些令牌的情况下下载私有存储库。我创建了一个个人访问令牌并将我的 Cargo.toml 更改为:
...
[dependencies]
b = { git = "https://ignore:MyPersonalAccessToken@github.com/me/b" }
但我从 Github 收到一封电子邮件,说我的令牌已被撤销,因为它不允许在代码中硬编码...
现在我不知道该怎么办。我可以将令牌放入我的 git 集线器秘密中,但我不知道我的 cargo.toml 如何使用它。
有没有简单的方法可以在 Github 操作中登录 git?我试过 https://github.com/OleksiyRudenko/gha-git-credentials 并像这样配置我的工作流程:
- uses: oleksiyrudenko/gha-git-credentials@v2-latest
with:
token: '${{ secrets.GIT_CREDENTIALS }}'
global: true
但是克隆还是失败:
Caused by: failed to authenticate when downloading repository
- attempted to find username/password via git's
credential.helper
support, but failed
我也尝试了库 https://github.com/marketplace/actions/setup-git-credentials,但我想我用错了它
问题
如何使用 Github 操作使 Cargo 克隆私有 git 存储库?
您可以在结帐步骤后添加此 action 并且 GitHub 可以访问您的私有存储库依赖项。
注意:- 确保将服务器的私钥添加为秘密,public 密钥到 GitHub SSH 密钥,请将您的私人仓库 URL 替换为 https+auth_token 到 SSH。
ssh://git@github.com/your_group/your_project.git
问题
我有一个私有 Rust 项目 (A),它依赖于另一个私有 Rust 项目 (B)。在我的本地机器上,它可以工作,因为我登录到 git。我不确定如何在 Github 操作中登录 git。我不确定是否需要。我读了很多关于 SSH 和 HTTPS 的东西,以至于我忘记了我必须做什么。
我看到了 https://github.com/webfactory/ssh-agent, https://github.com/fusion-engineering/setup-git-credentials 和其他一些操作,但我只是在猜测我需要做的事情,但我无法让它发挥作用。
设置
这是我在项目 A 中的 Cargo.toml 文件:
...
[dependencies]
b = { git = "https://github.com/me/b.git" }
这在 Github 操作中失败,因为 Github 操作无法在没有某些令牌的情况下下载私有存储库。我创建了一个个人访问令牌并将我的 Cargo.toml 更改为:
...
[dependencies]
b = { git = "https://ignore:MyPersonalAccessToken@github.com/me/b" }
但我从 Github 收到一封电子邮件,说我的令牌已被撤销,因为它不允许在代码中硬编码...
现在我不知道该怎么办。我可以将令牌放入我的 git 集线器秘密中,但我不知道我的 cargo.toml 如何使用它。
有没有简单的方法可以在 Github 操作中登录 git?我试过 https://github.com/OleksiyRudenko/gha-git-credentials 并像这样配置我的工作流程:
- uses: oleksiyrudenko/gha-git-credentials@v2-latest
with:
token: '${{ secrets.GIT_CREDENTIALS }}'
global: true
但是克隆还是失败:
Caused by: failed to authenticate when downloading repository
- attempted to find username/password via git's
credential.helper
support, but failed
我也尝试了库 https://github.com/marketplace/actions/setup-git-credentials,但我想我用错了它
问题
如何使用 Github 操作使 Cargo 克隆私有 git 存储库?
您可以在结帐步骤后添加此 action 并且 GitHub 可以访问您的私有存储库依赖项。
注意:- 确保将服务器的私钥添加为秘密,public 密钥到 GitHub SSH 密钥,请将您的私人仓库 URL 替换为 https+auth_token 到 SSH。
ssh://git@github.com/your_group/your_project.git