mirror of
https://github.com/easingthemes/ssh-deploy.git
synced 2025-06-21 12:02:09 +10:00
Feature/ssh cmd (#94)
* feat: Add SSH remote script support - before and after rsync * fix: remove __dirname * feat: add sshCmdArgs option * Add promise instead of callback * fix: improve logs * fix: Add simple command exists instead of a plugin * add non interactive install * feat: add onStderr and onStdout logs * Improve reject messages * feat: Add RSYNC_STDOUT env variable * emoji updates * fix: update workflow actions
This commit is contained in:
parent
a5d8edb941
commit
ec9347f8c6
17 changed files with 373 additions and 242 deletions
|
@ -1,11 +1,48 @@
|
|||
const inputNames = ['REMOTE_HOST', 'REMOTE_USER', 'REMOTE_PORT', 'SSH_PRIVATE_KEY', 'DEPLOY_KEY_NAME', 'SOURCE', 'TARGET', 'ARGS', 'EXCLUDE'];
|
||||
const { snakeToCamel } = require('./helpers');
|
||||
|
||||
const inputNames = [
|
||||
'REMOTE_HOST', 'REMOTE_USER', 'REMOTE_PORT',
|
||||
'SSH_PRIVATE_KEY', 'DEPLOY_KEY_NAME',
|
||||
'SOURCE', 'TARGET', 'ARGS', 'SSH_CMD_ARGS', 'EXCLUDE',
|
||||
'SCRIPT_BEFORE', 'SCRIPT_AFTER'];
|
||||
|
||||
const githubWorkspace = process.env.GITHUB_WORKSPACE;
|
||||
const remoteUser = process.env.REMOTE_USER;
|
||||
|
||||
const defaultInputs = {
|
||||
source: '',
|
||||
target: `/home/${remoteUser}/`,
|
||||
exclude: '',
|
||||
args: '-rltgoDzvO',
|
||||
sshCmdArgs: '-o StrictHostKeyChecking=no',
|
||||
deployKeyName: 'deploy_key'
|
||||
};
|
||||
|
||||
const inputs = {
|
||||
GITHUB_WORKSPACE: process.env.GITHUB_WORKSPACE
|
||||
githubWorkspace
|
||||
};
|
||||
|
||||
inputNames.forEach((input) => {
|
||||
inputs[input] = process.env[input] || process.env[`INPUT_${input}`];
|
||||
const inputName = snakeToCamel(input.toLowerCase());
|
||||
const inputVal = process.env[input] || process.env[`INPUT_${input}`];
|
||||
const validVal = inputVal === undefined ? defaultInputs[inputName] : inputVal;
|
||||
let extendedVal = validVal;
|
||||
// eslint-disable-next-line default-case
|
||||
switch (inputName) {
|
||||
case 'source':
|
||||
extendedVal = `${githubWorkspace}/${validVal}`;
|
||||
break;
|
||||
case 'exclude':
|
||||
case 'args':
|
||||
case 'sshCmdArgs':
|
||||
extendedVal = validVal.split(',').map((item) => item.trim());
|
||||
break;
|
||||
}
|
||||
|
||||
inputs[inputName] = extendedVal;
|
||||
});
|
||||
|
||||
inputs.sshServer = `${inputs.remoteUser}@${inputs.remoteHost}`;
|
||||
inputs.rsyncServer = `${inputs.remoteUser}@${inputs.remoteHost}:${inputs.target}`;
|
||||
|
||||
module.exports = inputs;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue