fix: fix default TARGET

This commit is contained in:
Dragan Filipovic 2023-02-21 15:36:29 +01:00
parent 056fb0fea7
commit 4d086346af
4 changed files with 8 additions and 15 deletions

View File

@ -22,7 +22,7 @@ inputs:
TARGET:
description: "Target directory"
required: false
default: "/home/REMOTE_USER/"
default: ""
ARGS:
description: "Arguments to pass to rsync"
required: false

2
dist/index.js vendored

File diff suppressed because one or more lines are too long

View File

@ -10,36 +10,29 @@ const githubWorkspace = process.env.GITHUB_WORKSPACE;
const remoteUser = process.env.REMOTE_USER || process.env.INPUT_REMOTE_USER;
const defaultInputs = {
source: '',
target: `/home/${remoteUser}/`,
exclude: '',
args: '-rlgoDzvc -i',
sshCmdArgs: '-o StrictHostKeyChecking=no',
deployKeyName: `deploy_key_${remoteUser}_${Date.now()}`
};
console.log('[DEFAULTS] default inputs', defaultInputs);
const inputs = {
githubWorkspace
};
inputNames.forEach((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;
const inputVal = process.env[input] || process.env[`INPUT_${input}`] || defaultInputs[inputName];
let extendedVal = inputVal;
// eslint-disable-next-line default-case
switch (inputName) {
case 'source':
extendedVal = validVal.split(' ').map((src) => `${githubWorkspace}/${src}`);
extendedVal = inputVal.split(' ').map((src) => `${githubWorkspace}/${src}`);
break;
case 'args':
extendedVal = validVal.split(' ');
extendedVal = inputVal.split(' ');
break;
case 'exclude':
case 'sshCmdArgs':
extendedVal = validVal.split(',').map((item) => item.trim());
extendedVal = inputVal.split(',').map((item) => item.trim());
break;
}

View File

@ -19,7 +19,7 @@ const addSshKey = (content, deployKeyName) => {
const { dir, filename } = getPrivateKeyPath(deployKeyName);
writeToFile({ dir, filename: KNOWN_HOSTS, content: '' });
console.log('✅ [SSH] known_hosts file ensured', dir);
writeToFile({ dir, filename, content, isRequired: true, mode: '0400' });
writeToFile({ dir, filename, content: `${content}\r\n`, isRequired: true, mode: '0400' });
console.log('✅ [SSH] key added to `.ssh` dir ', dir, filename);
};