[action] get input vars from ENV or WITH workflow settings

This commit is contained in:
Dragan Filipovic 2020-07-01 00:54:24 +02:00
parent a9e37f3cb5
commit 14eb503e62
2 changed files with 13 additions and 2 deletions

View File

@ -9,7 +9,7 @@ const {
REMOTE_PORT, SSH_PRIVATE_KEY, DEPLOY_KEY_NAME,
SOURCE, TARGET, ARGS,
GITHUB_WORKSPACE
} = process.env;
} = require('./inputs');
const defaultOptions = {
ssh: true,
@ -62,7 +62,7 @@ const run = () => {
validateInputs({ SSH_PRIVATE_KEY, REMOTE_HOST, REMOTE_USER });
sshDeploy.init({
src: `${GITHUB_WORKSPACE}/${SOURCE}` || '',
src: `${GITHUB_WORKSPACE}/${SOURCE || ''}`,
dest: TARGET || `/home/${REMOTE_USER}/`,
args: ARGS ? [ARGS] : ['-rltgoDzvO'],
host: REMOTE_HOST,

11
src/inputs.js Normal file
View File

@ -0,0 +1,11 @@
const inputNames = ['REMOTE_HOST', 'REMOTE_USER', 'REMOTE_PORT', 'SSH_PRIVATE_KEY', 'DEPLOY_KEY_NAME', 'SOURCE', 'TARGET', 'ARGS'];
const inputs = {
GITHUB_WORKSPACE: process.env.GITHUB_WORKSPACE
};
// Get inputs from ENV or WITH workflow settings
inputNames.forEach((input) => {
inputs[input] = process.env[input] || process.env[`INPUT_${input}`];
});
module.exports = inputs;