diff --git a/README.md b/README.md index 6387bc7..72b72e2 100644 --- a/README.md +++ b/README.md @@ -6,14 +6,16 @@ This action uploads an entire directory to your remote SFTP server on push. _(all default to an empty string)_ -| Name | Required? | Description | -| --------- | --------- | ------------------------------------------------------------------------------- | -| host | yes | SFTP server | -| port | yes | SFTP server port | -| username | yes | SFTP username | -| password | yes | SFTP password | -| sourceDir | yes | Source directory to upload from (will upload all files in this directory) | -| targetDir | yes | Remote directory to upload to (WARNING: overwrites ALL files in this directory) | +| Name | Required? | Description | +| ---------- | --------- | ------------------------------------------------------------------------------- | +| host | yes | SFTP server | +| port | yes | SFTP server port | +| username | no | SFTP username | +| password | no | SFTP password | +| sourceDir | yes | Source directory to upload from (will upload all files in this directory) | +| targetDir | yes | Remote directory to upload to (WARNING: overwrites ALL files in this directory) | +| privateKey | no | SSH key to authenticate with | +| passphrase | no | Passphrase for an encrypted private key | ## Example usage diff --git a/action.yml b/action.yml index 7d71f51..d4e4c40 100644 --- a/action.yml +++ b/action.yml @@ -11,12 +11,18 @@ inputs: default: '22' username: description: 'SFTP username' - required: true + required: false default: '' password: description: 'SFTP password' - required: true + required: false default: '' + privateKey: + description: "SSH Key" + required: false + passphrase: + description: "Passphrase for encrypted private keys" + required: false sourceDir: description: 'Source directory to upload from (will upload all files in this directory)' required: true diff --git a/index.js b/index.js index 4897ed2..a16dd6a 100644 --- a/index.js +++ b/index.js @@ -7,6 +7,8 @@ const username = core.getInput('username') const password = core.getInput('password') const sourceDir = core.getInput('sourceDir') const targetDir = core.getInput('targetDir') +const privateKey = core.getInput('privateKey') +const passphrase = core.getInput('passphrase') core.info(`connecting to ${username}@${host}:${port}...`) @@ -17,6 +19,8 @@ sftp port, username, password, + privateKey, + passphrase, readyTimeout: 5000, retries: 5, }) @@ -25,7 +29,7 @@ sftp return sftp.uploadDir(sourceDir, targetDir) }) .then(() => { - core.info(`succesfully uploaded ${sourceDir} to ${targetDir} 🎉`) + core.info(`successfully uploaded ${sourceDir} to ${targetDir} 🎉`) }) .catch((error) => { core.setFailed(error.message)