From 521a62f535d0078994b40c0c436f5854de79778a Mon Sep 17 00:00:00 2001 From: Alex Denvir Date: Fri, 22 Jul 2022 15:48:55 +0100 Subject: [PATCH 1/2] Add support for custom ssh port when using ssh_domain option --- action.yml | 5 +++++ composer-action.bash | 7 ++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/action.yml b/action.yml index 67a1b17..cb924da 100644 --- a/action.yml +++ b/action.yml @@ -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 @@ -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 diff --git a/composer-action.bash b/composer-action.bash index 4cd4820..8c367b0 100755 --- a/composer-action.bash +++ b/composer-action.bash @@ -33,7 +33,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 From 46733dee0b10bd71e6eb032c4289ccbef31a7f24 Mon Sep 17 00:00:00 2001 From: Alex Denvir Date: Fri, 22 Jul 2022 15:58:54 +0100 Subject: [PATCH 2/2] Update README --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index c102488..322f0ce 100644 --- a/README.md +++ b/README.md @@ -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: