NoK*_*Key 9 github rust rust-cargo github-actions
问题
我有一个私有 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" }
Run Code Online (Sandbox Code Playgroud)
这在 Github Actions 中失败,因为 Github Actions 无法在没有某些令牌的情况下下载私有存储库。我创建了一个个人访问令牌并将我的 Cargo.toml 更改为:
...
[dependencies]
b = { git = "https://ignore:MyPersonalAccessToken@github.com/me/b" }
Run Code Online (Sandbox Code Playgroud)
但我收到一封来自 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
Run Code Online (Sandbox Code Playgroud)
但克隆仍然失败:
原因:下载存储库时验证失败
- 尝试通过 git 的支持查找用户名/密码
credential.helper,但失败
我还尝试了库https://github.com/marketplace/actions/setup-git-credentials,但我想我使用不当
问题
如何使用 Github Actions 使 Cargo 克隆私有 git 存储库?
您可以在结帐步骤之后添加此操作,GitHub 可以访问您的私有存储库依赖项。
注意:- 确保将服务器的私钥作为秘密、公钥添加到 GitHub SSH 密钥,并将您的私有存储库 URL 从 https+auth_token 替换为 SSH。
ssh://git@github.com/your_group/your_project.git
| 归档时间: |
|
| 查看次数: |
4312 次 |
| 最近记录: |