game-ci / game-ci/unity-builder

Errors when following docs for multiple private repositories: Could not resolve hostname ?

Open
#634 6 comments 0 reactions 0 assignees View on GitHub
bug git private repo
Dominant language
TypeScript
Stars
1.1k
Forks
313
Avg merge
1h 39m
Merged PRs (30d)
1

Description

**Bug description**

After following instructions for multiple private GitHub repositories, the builder still fails to pull packages due to SSH hostname resolution errors.

This is the error message:

```
com.example.package: Error when executing git command. ssh: Could not resolve hostname key-somehashwashere.github.com: Name or service not known
fatal: Could not read from remote repository.

Please make sure you have the correct access rights and the repository exists.
```

Where `somehashwashere` is a 64-character hexadecimal string and `com.example.package` is my package name. I have 3 packages that all fail similarly with their own hostname not being able to resolve. I believe the error might lie in the step "Prepare SSH config for unity builder" copied from the documentation.

**How to reproduce**

I have 3 repositories hosted privately, and I followed the instructions as best I understood them. For each private repository, I generated a private/public key on my computer, and I used the git formatted URL as described in the docs so it can be used as a deploy key. This was done for each of my 3 private projects, the public keys were added to their individual deploy settings and the private keys were created as named secrets in my repository that I am trying to build.

```yml
name: Build Windows

on:
push:
tags:
- 'v[0-9]+.[0-9]+.[0-9]+'

workflow_dispatch:
inputs:
platform:
description: 'Platform'
required: true
default: 'all'
type: choice
options:
- all
- windows
#- macos
#- linux
jobs:
build-windows:
if: startsWith(github.ref, 'refs/tags/') || inputs.platform == 'windows' || inputs.platform == 'all'

name: Build Windows
runs-on: ubuntu-latest
steps:
# Checkout
- name: Checkout repository
uses: actions/checkout@v4
with:
lfs: false

- name: Add GitHub to the SSH known hosts file
run: |
mkdir -p -m 0700 $HOME/.ssh
curl --silent https://api.github.com/meta | jq --raw-output '"github.com "+.ssh_keys[]' >> $HOME/.ssh/known_hosts
chmod 600 $HOME/.ssh/known_hosts
shell: bash

- name: Setup SSH Agent
uses: webfactory/ssh-agent@v0.8.0
with:
ssh-private-key: |
${{ secrets.PRIVATE_SSH_KEY_ONE }}
${{ secrets.PRIVATE_SSH_KEY_TWO }}
${{ secrets.PRIVATE_SSH_KEY_THREE }}

- name: Prepare SSH config for unity builder
run: |
mkdir $HOME/.ssh_docker
cp $HOME/.ssh/config $HOME/.ssh_docker/
cp $HOME/.ssh/key* $HOME/.ssh_docker/
cp $HOME/.ssh/known_hosts $HOME/.ssh_docker/
sed -i 's/\/home\/runner/\/root/g' $HOME/.ssh_docker/config
sudo chown -R root:root $HOME/.ssh_docker
GIT_CONFIG_EXTENSIONS=$(git config --list | grep '^url\.')
{
echo 'GIT_CONFIG_EXTENSIONS<> "$GITHUB_ENV"
# Test DNS resolution and dump known hosts
cat $HOME/.ssh/known_hosts
hostname="key-57269d5d3ca57a1bf55ae7e38015720b3ab6c537c3668918b23b75ad4aeb6c84.github.com"
if nslookup $hostname >/dev/null 2>&1; then
echo "DNS resolution successful for $hostname"
exit 0 # Exit with success status
else
echo "DNS resolution failed for $hostname"
exit 0 # Still exit with success status to prevent job failure
fi
shell: bash

# Build
- name: Build project
uses: game-ci/unity-builder@v4
env:
UNITY_PASSWORD: ${{ secrets.UNITY_PASSWORD }}
UNITY_EMAIL: ${{ secrets.UNITY_EMAIL }}
UNITY_SERIAL: ${{ secrets.UNITY_SERIAL }}
with:
targetPlatform: StandaloneWindows64
sshAgent: ${{ env.SSH_AUTH_SOCK }}
sshPublicKeysDirectoryPath: ${{ env.HOME }}/.ssh_docker
versioning: Tag

# Output
- uses: actions/upload-artifact@v3
with:
name: Build
path: build
```

**Expected behavior**

Package manager is able to download packages from private repositories

**Additional details**

- The owner of the 3 private repositories is an organization I created but I am testing this with my personal account. I have access and I loaded the deploy keys directly to them.
- I tested with a single private SSH key previously but this resulted in a different error ( Error when executing git command. ssh_askpass: exec(/usr/bin/ssh-askpass): No such file or directory. Host key verification failed. )
- I had the same error about ssh_askpass with a public repository in the package manifest so I switched the protocol to HTTPS in the package manifest file, resolving it (since it was not private)
- I am using GitHub runners, not self-hosted. So they should be consistent

Contributor guide

Open the contributing guide

Research direction

Start with the documented “Prepare SSH config for unity builder” step and the workflow using game-ci/unity-builder@v4; inspect how ~/.ssh_docker, GIT_CONFIG_EXTENSIONS, sshAgent, and sshPublicKeysDirectoryPath are consumed. Re-run the shown workflow and compare the generated hostname with the DNS failure. Done means the builder downloads packages from all three private repositories.

Written by the indexing model from the issue text.

Assessment

Tech stack
bash, git, github-actions, typescript, unity
Domain
build-system, ci-cd, devops
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.