【发布时间】:2021-10-11 23:08:15
【问题描述】:
问题
我有一个私有 Rust 项目 (A),它依赖于另一个私有 Rust 项目 (B)。在我的本地机器上,它可以工作,因为我已登录 git。我不确定如何在 Github Actions 中登录 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 Actions 中失败,因为 Github Actions 在没有一些令牌的情况下无法下载私有存储库。我创建了一个个人访问令牌并将我的 Cargo.toml 更改为:
...
[dependencies]
b = { git = "https://ignore:MyPersonalAccessToken@github.com/me/b" }
但我从 Github 收到一封电子邮件,说我的令牌已被撤销,因为它不允许在代码中硬编码...
现在我不知道该怎么办。我可以将令牌放在我的 github 秘密中,但我不知道我的 cargo.toml 可以如何使用它。
有没有一种简单的方法可以在 Github Actions 中登录 git?我尝试了https://github.com/OleksiyRudenko/gha-git-credentials,并像这样配置了我的工作流程:
- uses: oleksiyrudenko/gha-git-credentials@v2-latest
with:
token: '${{ secrets.GIT_CREDENTIALS }}'
global: true
但是克隆仍然失败:
原因:下载存储库时验证失败
- 尝试通过 git 的
credential.helper查找用户名/密码 支持,但失败了
我也尝试了库https://github.com/marketplace/actions/setup-git-credentials,但我想我用错了
问题
如何使用 Github Actions 使 Cargo 克隆私有 git 存储库?
【问题讨论】:
-
为什么不使用
actions/checkout或其他操作在 github 操作工作流上克隆 repo。不兼容吗? -
这可能行得通,但我在 Github 工作人员上有一个克隆的 repo。我的 cargo.toml 文件会是什么样子?我不想引用本地路径
-
我猜 cargo.toml 文件必须引用运行器本地路径才能工作。因此,在您的情况下,这似乎不是一个选择:/
-
@GuiFalourd Nah,这是一个丑陋的解决方法......而不是每个(未来)私人回购,我需要在本地和 CI 工作人员上克隆它:(
标签: github rust github-actions rust-cargo