Set private-key as non required (#49)

Co-authored-by: benjaminmal <bbenben778@gmail.com>
This commit is contained in:
Benjamin 2022-10-01 18:13:45 +02:00 committed by GitHub
parent 56e7af68da
commit 162add4f19
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 17 additions and 13 deletions

@ -4,8 +4,8 @@
- name: Deploy - name: Deploy
uses: deployphp/action@v1 uses: deployphp/action@v1
with: with:
private-key: ${{ secrets.PRIVATE_KEY }}
dep: deploy dep: deploy
private-key: ${{ secrets.PRIVATE_KEY }}
``` ```
## Inputs ## Inputs
@ -14,16 +14,16 @@
- name: Deploy - name: Deploy
uses: deployphp/action@v1 uses: deployphp/action@v1
with: 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: # The deployer task to run. For example:
# `deploy all`. # `deploy all`.
# Required. # Required.
dep: deploy 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 # Content of `~/.ssh/known_hosts` file. The public SSH keys for a
# host may be obtained using the utility `ssh-keyscan`. # host may be obtained using the utility `ssh-keyscan`.
# For example: `ssh-keyscan deployer.org`. # For example: `ssh-keyscan deployer.org`.
@ -87,6 +87,6 @@ jobs:
- name: Deploy - name: Deploy
uses: deployphp/action@v1 uses: deployphp/action@v1
with: with:
private-key: ${{ secrets.PRIVATE_KEY }}
dep: deploy dep: deploy
private-key: ${{ secrets.PRIVATE_KEY }}
``` ```

@ -4,14 +4,15 @@ description: 'Deploy with Deployer'
inputs: inputs:
private-key:
required: true
description: The private key for connecting to remote hosts.
dep: dep:
required: true required: true
description: The command. description: The command.
private-key:
required: false
default: ''
description: The private key for connecting to remote hosts.
known-hosts: known-hosts:
required: false required: false
default: '' default: ''

@ -22,8 +22,11 @@ async function ssh() {
execa.sync('ssh-agent', ['-a', authSock]) execa.sync('ssh-agent', ['-a', authSock])
core.exportVariable('SSH_AUTH_SOCK', authSock) core.exportVariable('SSH_AUTH_SOCK', authSock)
let privateKey = core.getInput('private-key').replace('/\r/g', '').trim() + '\n' let privateKey = core.getInput('private-key')
execa.sync('ssh-add', ['-'], {input: privateKey}) if (privateKey !== '') {
privateKey = privateKey.replace('/\r/g', '').trim() + '\n'
execa.sync('ssh-add', ['-'], {input: privateKey})
}
const knownHosts = core.getInput('known-hosts') const knownHosts = core.getInput('known-hosts')
if (knownHosts !== '') { if (knownHosts !== '') {