I am using GitHub Actions to deploy to Azure. In this project I am using our own private repository's which we host on GitHub. These repository's will be installed during build and their links are stored in requirements.txt
, for example:
git+ssh://git@github.com/org-name/package-name.git
Locally, there is no problem installing the requirements, since I have access to these private repository's with SSH. But how would I access these during build in GitHub actions.
I get the error:
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.
Which makes sense, since it is a private repository.
You might try and include in your GitHub Action workflow the webfactory/ssh-agent
action:
When running a GitHub Action workflow to stage your project, run tests or build images, you might need to fetch additional libraries or vendors from private repositories.
GitHub Actions only have access to the repository they run for.
So, in order to access additional private repositories:
- create an SSH key with sufficient access privileges.
- Then, use this action to make the key available with ssh-agent on the Action worker node.
- Once this has been set up, git clone commands using ssh URLs will just work. Also, running ssh commands to connect to other servers will be able to use the key.
That would give a workflow like:
# .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