Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
ARPP3 opened this issue Feb 29, 2024 · 4 comments
Labels
bug Something isn't working git private repo

Comments

@ARPP3
Copy link

ARPP3 commented Feb 29, 2024

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.

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
@ARPP3 ARPP3 added the bug Something isn't working label Feb 29, 2024
@EmilianC
Copy link

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.

@DenverGylee
Copy link

DenverGylee commented Dec 16, 2024

I'd just like to add my feedback here that this seems consistent.

To add, while the unity-builder is running, I can docker exec -it CONTAINER_NAME bin/bash and then perform a git clone on one of the sub-packages and it is able to fully clone inside of the container. This seems to be something specific with how cloning is occuring by Unity, or the image rules, for packages.

@ARPP3
Copy link
Author

ARPP3 commented Dec 16, 2024

Hey @DenverGylee I forgot I had this issue open!

It's still broken, however,
game-ci/documentation#482 (comment)

I found a workaround here, scroll to my comment,

@GabLeRoux
Copy link
Member

Accepting pr in docs to fix using suggested workaround :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working git private repo
Projects
None yet
Development

No branches or pull requests

5 participants