-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.js
27 lines (26 loc) · 859 Bytes
/
index.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
const core = require('@actions/core');
const github = require('@actions/github');
const { exec } = require("child_process");
try {
const host = core.getInput('host');
const user = core.getInput('user');
const pass = core.getInput('pass');
const scriptPath = core.getInput('scriptPath');
const hk = core.getInput('hostkey');
let cmd = `psftp "${host}" -batch -bc -l "${user}" -pw "${pass}" -b ${scriptPath}`
if (hk) cmd += ` -hostkey ${hk}`
exec(cmd, (error, stdout, stderr) => {
if (error) {
console.log(`error: ${error.message}`);
core.setFailed(error.message);
return;
}
if (stderr) {
console.log(`stderr: ${stderr}`);
return;
}
console.log(`stdout: ${stdout}`);
});
} catch (error) {
core.setFailed(error.message);
}