mirror of
https://github.com/easingthemes/ssh-deploy.git
synced 2025-04-29 03:10:43 -04:00
Added option to pass sshCmdArgs to rsync command
This commit is contained in:
parent
f2f261e6bd
commit
0ea3812d3c
4 changed files with 20 additions and 7 deletions
|
@ -31,6 +31,10 @@ inputs:
|
||||||
description: "An array of folder to exclude"
|
description: "An array of folder to exclude"
|
||||||
required: false
|
required: false
|
||||||
default: ""
|
default: ""
|
||||||
|
SSH_CMD_ARGS:
|
||||||
|
description: "An array of ssh arguments, they must be prefixed with -o and separated by a comma, for example: -o SomeArgument=no, -o SomeOtherArgument=5 "
|
||||||
|
required: false
|
||||||
|
default: "-o StrictHostKeyChecking=no"
|
||||||
outputs:
|
outputs:
|
||||||
status:
|
status:
|
||||||
description: "Status"
|
description: "Status"
|
||||||
|
|
2
dist/index.js
vendored
2
dist/index.js
vendored
File diff suppressed because one or more lines are too long
19
src/index.js
19
src/index.js
|
@ -8,26 +8,34 @@ const {
|
||||||
REMOTE_HOST, REMOTE_USER,
|
REMOTE_HOST, REMOTE_USER,
|
||||||
REMOTE_PORT, SSH_PRIVATE_KEY, DEPLOY_KEY_NAME,
|
REMOTE_PORT, SSH_PRIVATE_KEY, DEPLOY_KEY_NAME,
|
||||||
SOURCE, TARGET, ARGS, EXCLUDE,
|
SOURCE, TARGET, ARGS, EXCLUDE,
|
||||||
|
SSH_CMD_ARGS,
|
||||||
GITHUB_WORKSPACE
|
GITHUB_WORKSPACE
|
||||||
} = require('./inputs');
|
} = require('./inputs');
|
||||||
|
|
||||||
const defaultOptions = {
|
const defaultOptions = {
|
||||||
ssh: true,
|
ssh: true,
|
||||||
sshCmdArgs: ['-o StrictHostKeyChecking=no'],
|
|
||||||
recursive: true
|
recursive: true
|
||||||
};
|
};
|
||||||
|
|
||||||
console.log('[general] GITHUB_WORKSPACE: ', GITHUB_WORKSPACE);
|
console.log('[general] GITHUB_WORKSPACE: ', GITHUB_WORKSPACE);
|
||||||
|
|
||||||
const sshDeploy = (() => {
|
const sshDeploy = (() => {
|
||||||
const rsync = ({ privateKey, port, src, dest, args, exclude }) => {
|
const rsync = ({ privateKey, port, src, dest, args, exclude, sshCmdArgs }) => {
|
||||||
console.log(`[Rsync] Starting Rsync Action: ${src} to ${dest}`);
|
console.log(`[Rsync] Starting Rsync Action: ${src} to ${dest}`);
|
||||||
|
|
||||||
if (exclude) console.log(`[Rsync] exluding folders ${exclude}`);
|
if (exclude) console.log(`[Rsync] exluding folders ${exclude}`);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// RSYNC COMMAND
|
// RSYNC COMMAND
|
||||||
nodeRsync({
|
nodeRsync({
|
||||||
src, dest, args, privateKey, port, excludeFirst: exclude, ...defaultOptions
|
src,
|
||||||
|
dest,
|
||||||
|
args,
|
||||||
|
privateKey,
|
||||||
|
port,
|
||||||
|
sshCmdArgs,
|
||||||
|
excludeFirst: exclude,
|
||||||
|
...defaultOptions
|
||||||
}, (error, stdout, stderr, cmd) => {
|
}, (error, stdout, stderr, cmd) => {
|
||||||
if (error) {
|
if (error) {
|
||||||
console.error('⚠️ [Rsync] error: ', error.message);
|
console.error('⚠️ [Rsync] error: ', error.message);
|
||||||
|
@ -45,12 +53,12 @@ const sshDeploy = (() => {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const init = ({ src, dest, args, host = 'localhost', port, username, privateKeyContent, exclude = [] }) => {
|
const init = ({ src, dest, args, host = 'localhost', port, username, privateKeyContent, exclude = [], sshCmdArgs = [] }) => {
|
||||||
validateRsync(() => {
|
validateRsync(() => {
|
||||||
const privateKey = addSshKey(privateKeyContent, DEPLOY_KEY_NAME || 'deploy_key');
|
const privateKey = addSshKey(privateKeyContent, DEPLOY_KEY_NAME || 'deploy_key');
|
||||||
const remoteDest = `${username}@${host}:${dest}`;
|
const remoteDest = `${username}@${host}:${dest}`;
|
||||||
|
|
||||||
rsync({ privateKey, port, src, dest: remoteDest, args, exclude });
|
rsync({ privateKey, port, src, dest: remoteDest, args, exclude, sshCmdArgs });
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -70,6 +78,7 @@ const run = () => {
|
||||||
port: REMOTE_PORT || '22',
|
port: REMOTE_PORT || '22',
|
||||||
username: REMOTE_USER,
|
username: REMOTE_USER,
|
||||||
privateKeyContent: SSH_PRIVATE_KEY,
|
privateKeyContent: SSH_PRIVATE_KEY,
|
||||||
|
sshCmdArgs: (SSH_CMD_ARGS || '').split(',').map((item) => item.trim()),
|
||||||
exclude: (EXCLUDE || '').split(',').map((item) => item.trim()) // split by comma and trim whitespace
|
exclude: (EXCLUDE || '').split(',').map((item) => item.trim()) // split by comma and trim whitespace
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
const inputNames = ['REMOTE_HOST', 'REMOTE_USER', 'REMOTE_PORT', 'SSH_PRIVATE_KEY', 'DEPLOY_KEY_NAME', 'SOURCE', 'TARGET', 'ARGS', 'EXCLUDE'];
|
const inputNames = ['REMOTE_HOST', 'REMOTE_USER', 'REMOTE_PORT', 'SSH_PRIVATE_KEY', 'DEPLOY_KEY_NAME', 'SOURCE', 'TARGET', 'ARGS', 'EXCLUDE', 'SSH_CMD_ARGS'];
|
||||||
|
|
||||||
const inputs = {
|
const inputs = {
|
||||||
GITHUB_WORKSPACE: process.env.GITHUB_WORKSPACE
|
GITHUB_WORKSPACE: process.env.GITHUB_WORKSPACE
|
||||||
|
|
Loading…
Add table
Reference in a new issue