checkout icon indicating copy to clipboard operation
checkout copied to clipboard

No support for custom SSH port

Open dieselburner opened this issue 2 years ago • 4 comments

Seems like github-server-url is dropping custom SSH port, while URL is valid:

- name: Check out repository code
  uses: actions/checkout@v3
  with:
    github-server-url: ssh://[email protected]:12345
    ssh-key: ${{ secrets.SSH_KEY }}

Excerpt from logs:

::save-state name=isPost::true
::add-matcher::/run/act/actions/actions-checkout@v3/dist/problem-matcher.json
Syncing repository: org/repo
::group::Getting Git version info
Working directory is '/org/repo'
[command]/usr/bin/git version
git version 2.30.2
::endgroup::
Temporarily overriding HOME='/tmp/9c8d9181-98bf-45f7-9d40-1aa261a81728' before making global git config changes
Adding repository directory to the temporary git global config as a safe directory
[command]/usr/bin/git config --global --add safe.directory /org/repo
::save-state name=setSafeDirectory::true
Deleting the contents of '/org/repo'
::save-state name=repositoryPath::/org/repo
::group::Initializing the repository
[command]/usr/bin/git init /org/repo
hint: Using 'master' as the name for the initial branch. This default branch name
hint: is subject to change. To configure the initial branch name to use in all
hint: of your new repositories, which will suppress this warning, call:
hint: 
hint: 	git config --global init.defaultBranch <name>
hint: 
hint: Names commonly chosen instead of 'master' are 'main', 'trunk' and
hint: 'development'. The just-created branch can be renamed via this command:
hint: 
hint: 	git branch -m <name>
Initialized empty Git repository in /org/repo/.git/
[command]/usr/bin/git remote add origin [email protected]:org/repo.git
::endgroup::
::group::Disabling automatic garbage collection
[command]/usr/bin/git config --local gc.auto 0
::endgroup::
::group::Setting up auth
[command]/usr/bin/git config --local --name-only --get-regexp core\.sshCommand
[command]/usr/bin/git submodule foreach --recursive git config --local --name-only --get-regexp 'core\.sshCommand' && git config --local --unset-all 'core.sshCommand' || :
[command]/usr/bin/git config --local --name-only --get-regexp http\.https\:\/\/git\.example\.com\:10000\/\.extraheader
[command]/usr/bin/git submodule foreach --recursive git config --local --name-only --get-regexp 'http\.https\:\/\/git\.example\.com\:10000\/\.extraheader' && git config --local --unset-all 'http.https://git.example.com:10000/.extraheader' || :
::save-state name=sshKeyPath::/tmp/5d03bc11-c322-4924-b7e2-a72407dbb54c
::save-state name=sshKnownHostsPath::/tmp/5d03bc11-c322-4924-b7e2-a72407dbb54c_known_hosts
Temporarily overriding GIT_SSH_COMMAND="/usr/bin/ssh" -i "$RUNNER_TEMP/5d03bc11-c322-4924-b7e2-a72407dbb54c" -o StrictHostKeyChecking=yes -o CheckHostIP=no -o "UserKnownHostsFile=$RUNNER_TEMP/5d03bc11-c322-4924-b7e2-a72407dbb54c_known_hosts"
[command]/usr/bin/git config --local core.sshCommand "/usr/bin/ssh" -i "$RUNNER_TEMP/5d03bc11-c322-4924-b7e2-a72407dbb54c" -o StrictHostKeyChecking=yes -o CheckHostIP=no -o "UserKnownHostsFile=$RUNNER_TEMP/5d03bc11-c322-4924-b7e2-a72407dbb54c_known_hosts"
[command]/usr/bin/git config --local http.https://git.example.com:10000/.extraheader AUTHORIZATION: basic ***
::endgroup::
::group::Fetching the repository
[command]/usr/bin/git -c protocol.version=2 fetch --no-tags --prune --progress --no-recurse-submodules --depth=1 origin +7965e47f829dbbebb91cd74d815073ced5508a02:refs/remotes/origin/master
ssh: connect to host git.example.com port 22: Network is unreachable
fatal: Could not read from remote repository.
...

dieselburner avatar May 12 '23 14:05 dieselburner

I have the same problem

Aurgil avatar Jun 21 '23 09:06 Aurgil

Hi, I have/had the same problem, but was able to fix it with a small hack: In a prior step I modify the ssh config to add a custom port. This is the config for that step.

Note: I'm using this on a gitea/act runner (running ubuntu:latest) so you might have to adjust it a little bit (e.g. paths). I also only tested it with v3, not any older or newer tags like v2 and v4.

    - name: Git Setup
      run: |
        mkdir -p ~/.ssh
        echo 'Host your_host_url ' >> ~/.ssh/config
        echo '    HostName your_host_url' >> ~/.ssh/config
        echo '    Port your_port' >> ~/.ssh/config
        cat  ~/.ssh/config

To use this, you have to replace your_host_url and your_port with, well, your host url and port respectively. You could use this to also change the user using echo ' User your_user' >> ~/.ssh/config or any other settings that can be modified in a ssh config.

Explanation: mkdir makes sure that the folder .ssh exists. The echo commands append the needed config to the config file. If none exists it will be created automatically. cat prints the contents of the config file for verification. This last command can be left out.

freeware-superman avatar Jan 22 '24 18:01 freeware-superman