Compare commits

...

9 Commits

Author SHA1 Message Date
github-actions
51b2009841 chore(release): 4.1.6 [skip ci]
## [4.1.6](https://github.com/easingthemes/ssh-deploy/compare/v4.1.5...v4.1.6) (2023-02-21)

### Bug Fixes

* [#118](https://github.com/easingthemes/ssh-deploy/issues/118) check undefined default values rebuild ([54f8b6c](54f8b6c60b))
2023-02-21 17:02:47 +00:00
Dragan Filipović
530a3691f2 Merge pull request #121 from easingthemes/bugfix/#118-default-value-check
Bugfix/#118 default value check
2023-02-21 18:02:04 +01:00
Dragan Filipovic
509caf1bb9 Merge branch 'main' into bugfix/#118-default-value-check 2023-02-21 18:01:00 +01:00
Dragan Filipovic
54f8b6c60b fix: #118 check undefined default values rebuild 2023-02-21 18:00:23 +01:00
github-actions
d9d134f8e5 chore(release): 4.1.5 [skip ci]
## [4.1.5](https://github.com/easingthemes/ssh-deploy/compare/v4.1.4...v4.1.5) (2023-02-21)

### Bug Fixes

* [#118](https://github.com/easingthemes/ssh-deploy/issues/118) check undefined default values ([f0c02fb](f0c02fb2a5))
2023-02-21 16:12:23 +00:00
Dragan Filipović
e7b2312bc9 Merge pull request #119 from easingthemes/bugfix/#118-default-value-check
fix: #118 check undefined default values
2023-02-21 17:11:53 +01:00
Dragan Filipovic
f0c02fb2a5 fix: #118 check undefined default values 2023-02-21 17:10:24 +01:00
github-actions
ae4970d4cf chore(release): 4.1.4 [skip ci]
## [4.1.4](https://github.com/easingthemes/ssh-deploy/compare/v4.1.3...v4.1.4) (2023-02-21)

### Bug Fixes

* [#113](https://github.com/easingthemes/ssh-deploy/issues/113) limit ssh script input ([5894f5e](5894f5e290))
2023-02-21 16:03:56 +00:00
Dragan Filipovic
5894f5e290 fix: #113 limit ssh script input 2023-02-21 17:03:16 +01:00
5 changed files with 36 additions and 8 deletions

2
dist/index.js vendored

File diff suppressed because one or more lines are too long

View File

@@ -1,3 +1,24 @@
## [4.1.6](https://github.com/easingthemes/ssh-deploy/compare/v4.1.5...v4.1.6) (2023-02-21)
### Bug Fixes
* [#118](https://github.com/easingthemes/ssh-deploy/issues/118) check undefined default values rebuild ([54f8b6c](https://github.com/easingthemes/ssh-deploy/commit/54f8b6c60b8f2f926d5ed9538557e5521a905d87))
## [4.1.5](https://github.com/easingthemes/ssh-deploy/compare/v4.1.4...v4.1.5) (2023-02-21)
### Bug Fixes
* [#118](https://github.com/easingthemes/ssh-deploy/issues/118) check undefined default values ([f0c02fb](https://github.com/easingthemes/ssh-deploy/commit/f0c02fb2a5b3b69bb91004dd49d409eb6adfe7cd))
## [4.1.4](https://github.com/easingthemes/ssh-deploy/compare/v4.1.3...v4.1.4) (2023-02-21)
### Bug Fixes
* [#113](https://github.com/easingthemes/ssh-deploy/issues/113) limit ssh script input ([5894f5e](https://github.com/easingthemes/ssh-deploy/commit/5894f5e29008feccaf42787330ec8f49f3ad50b0))
## [4.1.3](https://github.com/easingthemes/ssh-deploy/compare/v4.1.2...v4.1.3) (2023-02-21) ## [4.1.3](https://github.com/easingthemes/ssh-deploy/compare/v4.1.2...v4.1.3) (2023-02-21)

View File

@@ -1,6 +1,6 @@
{ {
"name": "@draganfilipovic/ssh-deploy", "name": "@draganfilipovic/ssh-deploy",
"version": "4.1.3", "version": "4.1.6",
"description": "Fast NodeJS action to deploy specific directory from `GITHUB_WORKSPACE` to a server via rsync over ssh.", "description": "Fast NodeJS action to deploy specific directory from `GITHUB_WORKSPACE` to a server via rsync over ssh.",
"main": "dist/index.js", "main": "dist/index.js",
"files": [ "files": [

View File

@@ -10,7 +10,11 @@ const githubWorkspace = process.env.GITHUB_WORKSPACE;
const remoteUser = process.env.REMOTE_USER || process.env.INPUT_REMOTE_USER; const remoteUser = process.env.REMOTE_USER || process.env.INPUT_REMOTE_USER;
const defaultInputs = { const defaultInputs = {
source: '',
target: `/home/${remoteUser}/`, target: `/home/${remoteUser}/`,
exclude: '',
args: '-rlgoDzvc -i',
sshCmdArgs: '-o StrictHostKeyChecking=no',
deployKeyName: `deploy_key_${remoteUser}_${Date.now()}` deployKeyName: `deploy_key_${remoteUser}_${Date.now()}`
}; };
@@ -21,18 +25,19 @@ const inputs = {
inputNames.forEach((input) => { inputNames.forEach((input) => {
const inputName = snakeToCamel(input.toLowerCase()); const inputName = snakeToCamel(input.toLowerCase());
const inputVal = process.env[input] || process.env[`INPUT_${input}`] || defaultInputs[inputName]; const inputVal = process.env[input] || process.env[`INPUT_${input}`] || defaultInputs[inputName];
let extendedVal = inputVal; const validVal = inputVal === undefined ? defaultInputs[inputName] : inputVal;
let extendedVal = validVal;
// eslint-disable-next-line default-case // eslint-disable-next-line default-case
switch (inputName) { switch (inputName) {
case 'source': case 'source':
extendedVal = inputVal.split(' ').map((src) => `${githubWorkspace}/${src}`); extendedVal = validVal.split(' ').map((src) => `${githubWorkspace}/${src}`);
break; break;
case 'args': case 'args':
extendedVal = inputVal.split(' '); extendedVal = validVal.split(' ');
break; break;
case 'exclude': case 'exclude':
case 'sshCmdArgs': case 'sshCmdArgs':
extendedVal = inputVal.split(',').map((item) => item.trim()); extendedVal = validVal.split(',').map((item) => item.trim());
break; break;
} }

View File

@@ -15,16 +15,18 @@ const remoteCmd = async (content, privateKeyPath, isRequired, label) => new Prom
const filename = `local_ssh_script-${label}.sh`; const filename = `local_ssh_script-${label}.sh`;
try { try {
writeToFile({ dir: githubWorkspace, filename, content }); writeToFile({ dir: githubWorkspace, filename, content });
const dataLimit = 10000;
const rsyncStdout = process.env.RSYNC_STDOUT.substring(0, dataLimit);
console.log(`Executing remote script: ssh -i ${privateKeyPath} ${sshServer}`); console.log(`Executing remote script: ssh -i ${privateKeyPath} ${sshServer}`);
exec( exec(
`DEBIAN_FRONTEND=noninteractive ssh -p ${(remotePort || 22)} -i ${privateKeyPath} -o StrictHostKeyChecking=no ${sshServer} 'RSYNC_STDOUT="${process.env.RSYNC_STDOUT}" bash -s' < ${filename}`, `DEBIAN_FRONTEND=noninteractive ssh -p ${(remotePort || 22)} -i ${privateKeyPath} -o StrictHostKeyChecking=no ${sshServer} 'RSYNC_STDOUT="${rsyncStdout}" bash -s' < ${filename}`,
(err, data, stderr) => { (err, data, stderr) => {
if (err) { if (err) {
const message = `⚠️ [CMD] Remote script failed: ${err.message}`; const message = `⚠️ [CMD] Remote script failed: ${err.message}`;
console.warn(`${message} \n`, data, stderr); console.warn(`${message} \n`, data, stderr);
handleError(message, isRequired, reject); handleError(message, isRequired, reject);
} else { } else {
const limited = data.substring(0, 10000); const limited = data.substring(0, dataLimit);
console.log('✅ [CMD] Remote script executed. \n', limited, stderr); console.log('✅ [CMD] Remote script executed. \n', limited, stderr);
resolve(limited); resolve(limited);
} }