unity-builder: Private Repositories bug
Bug description
I am trying to build my Unity Project to Android using the GameCI. My project uses private repositories with ssh. I follow the documentation and I put the SSH Agent step in my CI. I add the Deploy Key to my repository and add the secret key to Secrets.
But this error occurs:
com.company.utils: Error when executing git command. Failed to add the RSA host key for IP address '140.82.112.3' to the list of known hosts (/root/.ssh/known_hosts).
ERROR: Repository not found.
fatal: Could not read from remote repository.
I already try to add the ips in /home/runner/.ssh/known_hosts. The command below does not return errors:
Run ssh-keyscan 140.82.114.3 >> /home/runner/.ssh/known_hosts
ssh-keyscan 140.82.114.3 >> /home/runner/.ssh/known_hosts
shell: /usr/bin/bash -e {0}
env:
SSH_AUTH_SOCK: /tmp/ssh-BYQRT89SNPb3/agent.1664
SSH_AGENT_PID: 1665
# 140.82.114.3:22 SSH-2.0-babeld-968490c5
# 140.82.114.3:22 SSH-2.0-babeld-968490c5
# 140.82.114.3:22 SSH-2.0-babeld-968490c5
# 140.82.114.3:22 SSH-2.0-babeld-968490c5
# 140.82.114.3:22 SSH-2.0-babeld-968490c5
When I try to add to /root/.ssh/known_hosts, the error occurs:
Run ssh-keyscan github.com >> /root/.ssh/known_hosts
ssh-keyscan github.com >> /root/.ssh/known_hosts
shell: /usr/bin/bash -e {0}
env:
SSH_AUTH_SOCK: /tmp/ssh-3ZIaGpOiiIJn/agent.1641
SSH_AGENT_PID: 1642
/home/runner/work/_temp/8d9c2b71-d5e1-4648-b27e-5f695d8e3558.sh: line 1: /root/.ssh/known_hosts: Permission denied
Error: Process completed with exit code 1.
How to reproduce
-
Create a unity project that uses private repositories with ssh
-
Try to run CI Unity Build
Expected behavior
Build the project with success
CI File
name: Actions 😎
on: [push, pull_request]
jobs:
build:
name: Build Project ✨ for ${{ matrix.targetPlatform }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
projectPath:
- xproject-unity
unityVersion:
- 2020.3.11f1
targetPlatform:
- Android
steps:
# Checkout
- name: Checkout repository
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: SSH Agent
uses: webfactory/ssh-agent@v0.5.3
with:
ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }}
- name: Adding github to known_hosts
run: ssh-keyscan github.com >> /root/.ssh/known_hosts
- name: Adding github to known_hosts
run: ssh-keyscan 140.82.114.3 >> /root/.ssh/known_hosts
- name: Adding github to known_hosts
run: ssh-keyscan 140.82.114.4 >> /root/.ssh/known_hosts
# Cache
- uses: actions/cache@v2
with:
path: ${{ matrix.projectPath }}/Library
key: Library-${{ matrix.targetPlatform }}
restore-keys: |
Library-${{ matrix.targetPlatform }}-
Library-
# Build
- name: Build project
uses: game-ci/unity-builder@v2
env:
UNITY_LICENSE: ${{ secrets.UNITY_LICENSE }}
with:
sshAgent: ${{ env.SSH_AUTH_SOCK }}
projectPath: ${{ matrix.projectPath }}
unityVersion: ${{ matrix.unityVersion }}
targetPlatform: ${{ matrix.targetPlatform }}
versioning: Semantic
androidAppBundle: false
androidKeystoreName: x.keystore
androidKeystoreBase64: ${{ secrets.ANDROID_KEYSTORE_BASE64 }}
androidKeystorePass: ${{ secrets.ANDROID_KEYSTORE_PASS }}
androidKeyaliasName: ${{ secrets.ANDROID_KEYALIAS_NAME }}
androidKeyaliasPass: ${{ secrets.ANDROID_KEYALIAS_PASS }}
# Output
- uses: actions/upload-artifact@v2
with:
name: Build-${{ matrix.targetPlatform }}
path: build/${{ matrix.targetPlatform }}
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 1
- Comments: 18 (8 by maintainers)
If you have access to
sudo, maybe you can try| sudo tee -alike this:I just confirmed that this fixes the permission issue you’re getting:
https://github.com/GabLeRoux/283-private-repositories/pull/1/files
Before the fix:
After the fix:
🚀
ip is
140.82.112.4in above error message, but the ones you are adding here are different:I know they’re close, but there’s a small difference:
140.82.114.3 140.82.114.4 140.82.112.4 <-- the ip from your error
😉
Try also adding this maybe?
Same error here. how can i access sudo in github workflow?
Thanks! I will try this fix and post here the result.