Unable to import packages from private repo
See original GitHub issueBug description
Have two packages hosted on github as private repos.
Getting this error:
An error occurred while resolving packages:
Project has invalid dependencies:
<package_id>: Error when executing git command. Failed to add the ECDSA host key for IP address '140.82.114.4' to the list of known hosts (/root/.ssh/known_hosts).
ERROR: Repository not found.
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
(140.82.114.4 is a github.com ip)
How to reproduce
Yaml snippet:
# setup ssh agent to access private package repos in manifest
- uses: webfactory/ssh-agent@v0.5.4
with:
ssh-private-key: |
${{ secrets.SSH_PRIVATE_KEY }}
${{ secrets.SSH_PRIVATE_KEY_TWO }}
# test git clone (this successfully clones the repos, suggesting ssh-agent is setup properly)
# - name: Git Clone Test
# run: |
# git clone git@github.com:<repo_1>.git
# git clone git@github.com:<repo_2>.git
# cd <repo_folder>
# ls
# Build
- name: Build project
uses: game-ci/unity-builder@v2
env:
UNITY_EMAIL: ${{ secrets.UNITY_EMAIL }}
UNITY_PASSWORD: ${{ secrets.UNITY_PASSWORD }}
UNITY_SERIAL: ${{ secrets.UNITY_SERIAL }}
with:
targetPlatform: iOS
sshAgent: ${{ env.SSH_AUTH_SOCK }}
Format in manifest is: ssh://git@github.com/<company>/<project>.git
Expected behavior
I expect it to successfully import these packages
Additional details
Followed these docs: https://game.ci/docs/github/builder#private-github-repositories And ssh-agent docs: https://github.com/webfactory/ssh-agent
As per ssh-agent recommendations found, I also tried manually cloning the repos (see yaml) – this worked fine, so I don’t think there’s an issue with my ssh-agent setup. Seems to break only when importing packages. If it matters, I did notice this log when I manually cloned: Warning: Permanently added the ECDSA host key for IP address '140.82.114.3' to the list of known hosts.
(140.82.114.3 is another github ip). Maybe the problem has to do with it failing to do so in unity-builder container?
Also tried webfactory/ssh-agent@v0.5.2
(what’s currently in Game-CI docs).
Have tried other formats in the manifest (one above seems closest to what Unity prescribes) with no luck. Tried the url format in terminal and it seems to work:
Hi <company>/<project>! You've successfully authenticated, but GitHub does not provide shell access.
So as far as I can tell, I have everything configured correctly on my end. Any ideas?
Issue Analytics
- State:
- Created 2 years ago
- Comments:12 (2 by maintainers)
Top GitHub Comments
This clones the package repos locally (you still need to setup ssh-agent correctly for multiple private repos, see my snippets above) and runs a shell script to set the package manifest to point to the local files (and prints the manifest file so you can confirm the changes worked as you intended)
edit_packages.sh looks like this:
the
sed
command is simple string replacement –s|<string to replace>|<string to replace it with>|
Because you’re editing stuff after checkout, you’ll need to set
allowDirtyBuild: true
in the unity-builder step’swith
sectionyou may have to mess with paths depending on your setup – just make sure the packages are cloned outside the Assets folder and that the package manifest points to the path you cloned them to.
and for clarity, this workaround doesn’t require a custom fork of unity-builder
I have a workaround but it’s not ideal – I just clone the repos outside of the docker container and reference the files locally in the package manifest. Requires me to enable dirty builds, which I’d like to avoid but it’s fine for now.
I think this is related to unity-builder not correctly implementing support for multiple keys inside the docker container: https://github.com/webfactory/ssh-agent/issues/78
I tried forking my own unity-builder to apply the suggested fix, got close but couldn’t get it working quickly enough so I gave up.