From 162add4f1964041be37d8235ca68bed2e2790a4c Mon Sep 17 00:00:00 2001 From: Benjamin <58468686+benjaminmal@users.noreply.github.com> Date: Sat, 1 Oct 2022 18:13:45 +0200 Subject: [PATCH] Set `private-key` as non required (#49) Co-authored-by: benjaminmal --- README.md | 14 +++++++------- action.yaml | 9 +++++---- index.js | 7 +++++-- 3 files changed, 17 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index b31a6f4..c315404 100644 --- a/README.md +++ b/README.md @@ -4,8 +4,8 @@ - name: Deploy uses: deployphp/action@v1 with: - private-key: ${{ secrets.PRIVATE_KEY }} dep: deploy + private-key: ${{ secrets.PRIVATE_KEY }} ``` ## Inputs @@ -14,16 +14,16 @@ - name: Deploy uses: deployphp/action@v1 with: - # Private key for connecting to remote hosts. To generate private key: - # `ssh-keygen -o -t rsa -C 'action@deployer.org'`. - # Required. - private-key: ${{ secrets.PRIVATE_KEY }} - # The deployer task to run. For example: # `deploy all`. # Required. dep: deploy + # Private key for connecting to remote hosts. To generate private key: + # `ssh-keygen -o -t rsa -C 'action@deployer.org'`. + # Optional. + private-key: ${{ secrets.PRIVATE_KEY }} + # Content of `~/.ssh/known_hosts` file. The public SSH keys for a # host may be obtained using the utility `ssh-keyscan`. # For example: `ssh-keyscan deployer.org`. @@ -87,6 +87,6 @@ jobs: - name: Deploy uses: deployphp/action@v1 with: - private-key: ${{ secrets.PRIVATE_KEY }} dep: deploy + private-key: ${{ secrets.PRIVATE_KEY }} ``` diff --git a/action.yaml b/action.yaml index f5496d3..598b8de 100644 --- a/action.yaml +++ b/action.yaml @@ -4,14 +4,15 @@ description: 'Deploy with Deployer' inputs: - private-key: - required: true - description: The private key for connecting to remote hosts. - dep: required: true description: The command. + private-key: + required: false + default: '' + description: The private key for connecting to remote hosts. + known-hosts: required: false default: '' diff --git a/index.js b/index.js index efe01ba..d75e719 100644 --- a/index.js +++ b/index.js @@ -22,8 +22,11 @@ async function ssh() { execa.sync('ssh-agent', ['-a', authSock]) core.exportVariable('SSH_AUTH_SOCK', authSock) - let privateKey = core.getInput('private-key').replace('/\r/g', '').trim() + '\n' - execa.sync('ssh-add', ['-'], {input: privateKey}) + let privateKey = core.getInput('private-key') + if (privateKey !== '') { + privateKey = privateKey.replace('/\r/g', '').trim() + '\n' + execa.sync('ssh-add', ['-'], {input: privateKey}) + } const knownHosts = core.getInput('known-hosts') if (knownHosts !== '') {