Open TrevorGibson-SR opened 1 year ago
I was able to solve the issue of cloning a single non-GitHub private repo in the Docker container by adding that repository's server to the known_hosts
file. I believe this is what was causing the build process to hang as it was waiting for user input to add the server to the list of known hosts.
This was fixed by issuing the following command immediately after the ssh-agent
action in my GitHub workflow:
ssh-keyscan -H bitbucket.org >> ~/.ssh/known_hosts
After investigating the contents of the known_hosts
file, it appears that github.com had already been added (either by the workflow managing agent, or by the ssh-agent
action), which is why there weren't any issues cloning GitHub repositories.
This solution should work for repositories hosted on any non-GitHub servers... just replace bitbucket.org
with the repo server's domain.
The root cause is due to the configuration created by webfactory/ssh-agent with the deploy key mapping feature. The custom .gitconfig settings are not copied into the docker automatically, therefore not allowing more than one private GitHub repo to be cloned.
This can be resolved by passing both the ~/.gitconfig
file and ~/.ssh
directory as mapped locations into the docker container. For an immediate fix, use the DOCKER_RUN_OPTS
parameter to specify the locations to map in your Github Actions workflow yaml file.
A more permanent fix has been submitted as a PR to incorporate mapping these locations as part of the standard codebase.
I'm having some trouble with this as well, but I haven't caught up with @TrevorGibson-SR yet.
Basically I've followed the instructions in index.rst:
In "Add a variable" section, fill in the following text field/area.
Key: SSH_PRIVATE_KEY
Except I have 4 private repositories, so I figured it might work to add 4 such private keys (with the corresponding public keys in the corresponding 4 private repos).
SSH_PRIVATE_KEY_1
, SSH_PRIVATE_KEY_2
, ..., SSH_PRIVATE_KEY_4
But, that doesn't work. industrial_ci
hangs forever when running in Github. Any simple solution to this?
@AndyZe: Just add something like this to your before_script in .gitlab-ci.ym
l
Just saw that you are talking about Github as well..
The SSH auto-setup is only implemented for Gitlab.
However, a similar trick should work with Github. As far as I can tell, that's whatwebfactory/ssh-agent
is doing under the hood.
As @TrevorGibson-SR already pointed out: it is crucial to setup the known hosts properly.
Multiple deploy keys should work withwebfactory/ssh-agent
and #844
Hi all,
I've been trying to get a GitHub Actions CI build to work with cloning more than one private repository, but have run into multiple issues and can't seem to resolve them.
Overview
The current Action I have set up works fine specifically when only 1 private GitHub repository is listed in our
.repos
file. It breaks when either a second private GitHub repo is listed (issue 1), or any private BitBucket repositories are listed (issue 2).Some additional information:
vcs import
) works fine, regardless of the source of those repos (GitHub or BitBucket)Here is a snippet of the .yml action showing the steps being run (placeholders in place of actual repo URLs):
KEY1
,KEY2
, andKEY3
are action secrets defined in the main repository, and contain the private keys for the corresponding private repositories we want to clone.Issue 1: Action fails when cloning a second private GitHub repository
Prior to running the industrial CI step, I have an
ssh-agent
step to load the SSH keys and allow for cloning private repositories. The output from this step indicates that the keys are being scanned and added correctly. Additionally, I have added the repository links for the GitHub repos as comments for the keys to use the deploy key mapping feature of thessh-agent
action (actual keys/hashes redacted for security):However, during the cloning process in the industrial CI step, only the repository for the first key listed is successfully cloned. If I switch the key order in the .yml action file, the successfully clone repository changes as well. Failure output:
Issue 2: Action hangs when cloning any number of private BitBucket repositories
Similar to above, the
ssh-agent
step successfully loads the SSH keys prior to running the industrial CI step. When a private BitBucket repo is listed in the.repos file
, the action hangs during thecolcon_setup
portion and must be manually cancelled. It always hangs at the same point, prior to even attempting to clone the repos in the.repos
file. Output log:Summary
Any help with either of these issues would be greatly appreciated. Ideally I would like to use the BitBucket private repo as it works better with the larger project architecture. However, cloning multiple private GitHub repositories is also a must for another project, so resolving that one alone will be helpful as well.
Thanks in advance