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.
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<<EOF'
echo "$GIT_CONFIG_EXTENSIONS"
echo EOF
} >> "$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
Hey, I had the same issue not being able to resolve the hostname on a github runner. I moved my packages to be local packages tracked in the repository, but this would be nice if it could get resolved.
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:
Where
somehashwashere
is a 64-character hexadecimal string andcom.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.
Expected behavior
Package manager is able to download packages from private repositories
Additional details