我正在使用GitHub Actions部署到Azure。在这个项目中,我使用我们自己的私有存储库,该存储库托管在GitHub上。这些存储库将在构建期间安装,其链接存储在requirements.txt
中,例如:
git+ssh://git@github.com/org-name/package-name.git
在本地,安装需求没有问题,因为我可以使用SSH访问这些专用存储库。但是在GitHub操作中构建过程中如何访问它们。
我得到了错误:
Collecting git+ssh://****@github.com/org-name/package-name.git (from -r requirements.txt (line 1))
Cloning ssh://****@github.com/org-nam/package-name.git to /tmp/pip-req-build-9nud9608
ERROR: Command errored out with exit status 128: git clone -q 'ssh://****@github.com/org-name/package-name.git' /tmp/pip-req-build-9nud9608 Check the logs for full command output.
Error: Process completed with exit code 1.
这是有道理的,因为它是一个私有存储库。
答案 0 :(得分:1)
您可以尝试在webfactory/ssh-agent
操作中加入GitHub操作工作流:
在运行GitHub Action工作流以暂存项目,运行测试或生成映像时,您可能需要从私有存储库中获取其他库或供应商。
GitHub动作只能访问运行它们的存储库。
因此,为了访问其他私有存储库:
- 创建具有足够访问权限的SSH密钥。
- 然后,使用此操作使该密钥可用于Action辅助节点上的ssh-agent。
- 设置好后,使用ssh URL的git clone命令将起作用。另外,运行ssh命令以连接到其他服务器将能够使用该密钥。
这将使工作流程如下:
# .github/workflows/my-workflow.yml
jobs:
my_job:
...
steps:
- actions/checkout@v1
# Make sure the @v0.4.1 matches the current version of the
# action
- uses: webfactory/ssh-agent@v0.4.1
with:
ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }}
- ... other steps