mirror of
https://github.com/easingthemes/ssh-deploy.git
synced 2025-06-22 12:32:09 +10:00
Add option to execute script before and after rsync
This commit is contained in:
parent
0e7d8019db
commit
5dfe8ebb5a
14 changed files with 278 additions and 213 deletions
|
@ -0,0 +1,27 @@
|
|||
const { join } = require('path');
|
||||
const { exec } = require('child_process');
|
||||
|
||||
const { sshServer, githubWorkspace } = require('./inputs');
|
||||
const { writeToFile } = require('./helpers');
|
||||
|
||||
const remoteCmd = (cmd, label) => {
|
||||
const localScriptPath = join(githubWorkspace, `local_ssh_script-${label}.sh`);
|
||||
try {
|
||||
writeToFile(localScriptPath, cmd);
|
||||
|
||||
exec(`ssh ${sshServer} 'bash -s' < ${localScriptPath}`, (err, data, stderr) => {
|
||||
if (err) {
|
||||
console.log('⚠️ [CMD] Remote script failed. ', err.message);
|
||||
} else {
|
||||
console.log('✅ [CMD] Remote script executed. \n', data, stderr);
|
||||
}
|
||||
});
|
||||
} catch (err) {
|
||||
console.log('⚠️ [CMD] Starting Remote script execution failed. ', err.message);
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
remoteCmdBefore: (cmd) => remoteCmd(cmd, 'before'),
|
||||
remoteCmdAfter: (cmd) => remoteCmd(cmd, 'after')
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue