feat: Add multi source and multi target support

This commit is contained in:
Dragan Filipovic 2023-01-03 02:49:54 +01:00
parent 98ee38d52e
commit 73a65ec97c
9 changed files with 227 additions and 70 deletions

View file

@ -10,12 +10,12 @@ const githubWorkspace = process.env.GITHUB_WORKSPACE;
const remoteUser = process.env.REMOTE_USER;
const defaultInputs = {
source: '',
source: './',
target: `/home/${remoteUser}/`,
exclude: '',
args: '-rltgoDzvO',
sshCmdArgs: '-o StrictHostKeyChecking=no',
deployKeyName: 'deploy_key'
deployKeyName: `deploy_key_${remoteUser}_${Date.now()}`
};
const inputs = {
@ -29,6 +29,9 @@ inputNames.forEach((input) => {
let extendedVal = validVal;
// eslint-disable-next-line default-case
switch (inputName) {
case 'source':
extendedVal = validVal.indexOf(' ') > -1 ? validVal.split(' ') : validVal;
break;
case 'args':
extendedVal = validVal.split(' ');
break;

View file

@ -17,7 +17,7 @@ const remoteCmd = async (content, privateKeyPath, isRequired, label) => new Prom
writeToFile({ dir: githubWorkspace, filename, content });
console.log(`Executing remote script: ssh -i ${privateKeyPath} ${sshServer}`);
exec(
`DEBIAN_FRONTEND=noninteractive ssh -i ${privateKeyPath} ${sshServer} 'RSYNC_STDOUT="${process.env.RSYNC_STDOUT}" bash -s' < ${filename}`,
`DEBIAN_FRONTEND=noninteractive ssh -i ${privateKeyPath} -o StrictHostKeyChecking=no ${sshServer} 'RSYNC_STDOUT="${process.env.RSYNC_STDOUT}" bash -s' < ${filename}`,
(err, data, stderr) => {
if (err) {
const message = `⚠️ [CMD] Remote script failed: ${err.message}`;

View file

@ -55,7 +55,7 @@ const rsyncCli = async ({
privateKeyPath, args, sshCmdArgs
}) => {
console.log(`[Rsync] Starting Rsync Action: ${source} to ${rsyncServer}`);
if (exclude) console.log(`[Rsync] excluding folders ${exclude}`);
if (exclude && exclude.length > 0) console.log(`[Rsync] excluding folders ${exclude}`);
const defaultOptions = {
ssh: true,