diff --git a/.gitignore b/.gitignore index ba32f0a..623377c 100644 --- a/.gitignore +++ b/.gitignore @@ -17,3 +17,5 @@ node_modules/ .env .env.test +# jetbrains +.idea diff --git a/README.md b/README.md index b60bebe..11db068 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,11 @@ Pass configuration with `env` vars 1. `SSH_PRIVATE_KEY` [required] -This should be the private key part of an ssh key pair. The public key part should be added to the authorized_keys file on the server that receives the deployment. +This should be the private key part of an ssh key pair. +The public key part should be added to the authorized_keys file on the server that receives the deployment. + +The keys should be generated using the PEM format. You can use this command +`ssh-keygen -m PEM -t rsa -b 4096` 2. `REMOTE_HOST` [required] diff --git a/dist/index.js b/dist/index.js index da1967b..858600f 100755 --- a/dist/index.js +++ b/dist/index.js @@ -492,6 +492,9 @@ const sshDeploy = (() => { nodeRsync({ src, dest, args, privateKey, ssh: true, port, sshCmdArgs: ['-o StrictHostKeyChecking=no'], recursive: true }, (error, stdout, stderr, cmd) => { if (error) { console.error('⚠️ Rsync error', error.message); + console.log('stderr: ', stderr); + console.log('stdout: ', stdout); + console.log('cmd: ', cmd); process.abort(); } else { console.log("✅ Rsync finished.", stdout); @@ -504,14 +507,14 @@ const sshDeploy = (() => { }; const init = ({ - src, - dest, - args, - host = 'localhost', - username, - privateKeyContent, - port - }) => { + src, + dest, + args, + host = 'localhost', + username, + privateKeyContent, + port + }) => { validateRsync(() => { const privateKey = addSshKey(privateKeyContent, DEPLOY_KEY_NAME ||'deploy_key'); @@ -596,26 +599,27 @@ const sshDeploy = (() => { })(); const validateInputs = (inputs) => { - const validInputs = inputs.filter(input => { + const validInputs = Object.keys(inputs).filter((key) => { + const input = inputs[key]; if (!input) { - console.error(`⚠️ ${input} is mandatory`); + console.error(`⚠️ ${key} is mandatory`); } return input; }); - if (validInputs.length !== inputs.length) { + if (validInputs.length !== Object.keys(inputs).length) { process.abort(); } }; const run = () => { - validateInputs([SSH_PRIVATE_KEY, REMOTE_HOST, REMOTE_USER]); + validateInputs({SSH_PRIVATE_KEY, REMOTE_HOST, REMOTE_USER}); sshDeploy.init({ src: GITHUB_WORKSPACE + '/' + SOURCE || '', dest: TARGET || '/home/' + REMOTE_USER + '/', - args: [ARGS] || false, + args: ARGS ? [ARGS] : ['-rltgoDzvO'], host: REMOTE_HOST, port: REMOTE_PORT || '22', username: REMOTE_USER, diff --git a/src/index.js b/src/index.js index 5a5ed28..216db25 100644 --- a/src/index.js +++ b/src/index.js @@ -17,6 +17,9 @@ const sshDeploy = (() => { nodeRsync({ src, dest, args, privateKey, ssh: true, port, sshCmdArgs: ['-o StrictHostKeyChecking=no'], recursive: true }, (error, stdout, stderr, cmd) => { if (error) { console.error('⚠️ Rsync error', error.message); + console.log('stderr: ', stderr); + console.log('stdout: ', stdout); + console.log('cmd: ', cmd); process.abort(); } else { console.log("✅ Rsync finished.", stdout); @@ -29,14 +32,14 @@ const sshDeploy = (() => { }; const init = ({ - src, - dest, - args, - host = 'localhost', - username, - privateKeyContent, - port - }) => { + src, + dest, + args, + host = 'localhost', + username, + privateKeyContent, + port + }) => { validateRsync(() => { const privateKey = addSshKey(privateKeyContent, DEPLOY_KEY_NAME ||'deploy_key'); @@ -121,21 +124,22 @@ const sshDeploy = (() => { })(); const validateInputs = (inputs) => { - const validInputs = inputs.filter(input => { + const validInputs = Object.keys(inputs).filter((key) => { + const input = inputs[key]; if (!input) { - console.error(`⚠️ ${input} is mandatory`); + console.error(`⚠️ ${key} is mandatory`); } return input; }); - if (validInputs.length !== inputs.length) { + if (validInputs.length !== Object.keys(inputs).length) { process.abort(); } }; const run = () => { - validateInputs([SSH_PRIVATE_KEY, REMOTE_HOST, REMOTE_USER]); + validateInputs({SSH_PRIVATE_KEY, REMOTE_HOST, REMOTE_USER}); sshDeploy.init({ src: GITHUB_WORKSPACE + '/' + SOURCE || '',