Skip to content

Commit

Permalink
Merge pull request #85 from attractions-io/custom-ssh-port-support
Browse files Browse the repository at this point in the history
Custom ssh port support
  • Loading branch information
g105b authored Nov 9, 2022
2 parents 20dfbf4 + 46733de commit bcb6305
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ Installing private repositories

To install from a private repository, SSH authentication must be used. Generate an SSH key pair for this purpose and add it to your private repository's configuration, preferable with only read-only privileges. On Github for instance, this can be done by using [deploy keys][deploy-keys].

Add the key pair to your project using [Github Secrets][secrets], and pass them into the `php-actions/composer` action by using the `ssh_key` and `ssh_key_pub` inputs. If your private repository is stored on another server than github.com, you also need to pass the domain via `ssh_domain`.
Add the key pair to your project using [Github Secrets][secrets], and pass them into the `php-actions/composer` action by using the `ssh_key` and `ssh_key_pub` inputs. If your private repository is stored on another server than github.com, you also need to pass the domain via `ssh_domain`. If the private repository is configured to use a non-standard SSH port, you can configure this by passing `ssh_port`.

Example yaml, showing how to pass secrets:

Expand Down
5 changes: 5 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,10 @@ inputs:
description: The domain to gather SSH public keys for (automatic for github.com, gitlab.com, bitbucket.org)
required: false

ssh_port:
description: Custom port to use in conjunction with ssh_domain
required: false

working_dir:
description: Use the given directory as working directory
required: false
Expand Down Expand Up @@ -92,6 +96,7 @@ runs:
ACTION_SSH_KEY: ${{ inputs.ssh_key }}
ACTION_SSH_KEY_PUB: ${{ inputs.ssh_key_pub }}
ACTION_SSH_DOMAIN: ${{ inputs.ssh_domain }}
ACTION_SSH_PORT: ${{ inputs.ssh_port }}
ACTION_WORKING_DIR: ${{ inputs.working_dir }}
ACTION_MEMORY_LIMIT: ${{ inputs.memory_limit }}
id: composer_run
Expand Down
7 changes: 6 additions & 1 deletion composer-action.bash
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,12 @@ then

if [ -n "$ACTION_SSH_DOMAIN" ]
then
ssh-keyscan -t rsa "$ACTION_SSH_DOMAIN" >> ~/.ssh/known_hosts
if [ -n "$ACTION_SSH_PORT" ]
then
ssh-keyscan -t rsa -p $ACTION_SSH_PORT "$ACTION_SSH_DOMAIN" >> ~/.ssh/known_hosts
else
ssh-keyscan -t rsa "$ACTION_SSH_DOMAIN" >> ~/.ssh/known_hosts
fi
fi

echo "$ACTION_SSH_KEY" > ~/.ssh/action_rsa
Expand Down

0 comments on commit bcb6305

Please sign in to comment.