Skip to content

Commit

Permalink
Add usage of ssh key
Browse files Browse the repository at this point in the history
  • Loading branch information
Cyb3r-Jak3 committed Aug 21, 2021
1 parent 99a434e commit 62603f2
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 11 deletions.
18 changes: 10 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
10 changes: 8 additions & 2 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 5 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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}...`)

Expand All @@ -17,6 +19,8 @@ sftp
port,
username,
password,
privateKey,
passphrase,
readyTimeout: 5000,
retries: 5,
})
Expand All @@ -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)
Expand Down

0 comments on commit 62603f2

Please sign in to comment.