From 9082573e492a810854070ab2b7a6487b7647a6b8 Mon Sep 17 00:00:00 2001 From: Thomas Ali Date: Thu, 27 Oct 2022 16:52:29 +0100 Subject: [PATCH] Add self-hosted option to action + This skips over the SSH configuration part of the action. + This is because self-hosted runners would typically have SSH already running causing ssh-agent command to throw an error (process already exists/port in use) --- README.md | 4 ++++ action.yaml | 5 +++++ index.js | 4 ++++ 3 files changed, 13 insertions(+) diff --git a/README.md b/README.md index c315404..26f0230 100644 --- a/README.md +++ b/README.md @@ -19,6 +19,10 @@ # Required. dep: deploy + # Option to skip over the SSH setup/configuration + # Self hosted runners don't need the SSH configuration or the SSH agent to be started + self-hosted: false + # Private key for connecting to remote hosts. To generate private key: # `ssh-keygen -o -t rsa -C 'action@deployer.org'`. # Optional. diff --git a/action.yaml b/action.yaml index 598b8de..5060666 100644 --- a/action.yaml +++ b/action.yaml @@ -8,6 +8,11 @@ inputs: required: true description: The command. + self-hosted: + required: false + default: 'false' + description: Whether the action is running on a self-hosted runner. + private-key: required: false default: '' diff --git a/index.js b/index.js index d75e719..a3f24fb 100644 --- a/index.js +++ b/index.js @@ -12,6 +12,10 @@ void async function main() { }() async function ssh() { + if (core.getBooleanInput('self-hosted')) { + return; + } + let sshHomeDir = `${process.env['HOME']}/.ssh` if (!fs.existsSync(sshHomeDir)) {