forked from wangyucode/sftp-upload-action
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsftp.js
37 lines (32 loc) · 1.47 KB
/
sftp.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
const { deploy } = require('sftp-sync-deploy');
const core = require('@actions/core');
const github = require('@actions/github');
console.log(core.getInput('dryRun'));
let config = {
host: core.getInput('host'), // Required.
port: core.getInput('port'), // Optional, Default to 22.
username: core.getInput('username'), // Required.
password: core.getInput('password'), // Optional.
// privateKey: '/path/to/key.pem', // Optional.
// passphrase: 'passphrase', // Optional.
// agent: '/path/to/agent.sock', // Optional, path to the ssh-agent socket.
localDir: core.getInput('localDir'), // Required, Absolute or relative to cwd.
remoteDir: core.getInput('remoteDir') // Required, Absolute path only.
};
let options = {
dryRun: JSON.parse(core.getInput('dryRun')), // Enable dry-run mode. Default to false
excludeMode: JSON.parse(core.getInput('excludeMode')), // Behavior for excluded files ('remove' or 'ignore'), Default to 'remove'.
forceUpload: JSON.parse(core.getInput('forceUpload')), // Force uploading all files, Default to false(upload only newer files).
exclude: JSON.parse(core.getInput('exclude')), // exclude patterns (glob)
concurrency: JSON.parse(core.getInput('concurrency'))
};
console.log('sftp options:', options)
deploy(config, options)
.then(() => {
console.log('sftp upload success!');
})
.catch(err => {
console.log('sftp options:', options)
console.error('sftp upload error! ', err);
core.setFailed(err.message)
});