add optional REMOTE_PORT env to configuration

This commit is contained in:
Filip Malinowski 2019-12-29 15:36:34 +01:00
parent a3d2df0501
commit 0d77a6681b
6 changed files with 44 additions and 33 deletions

12
dist/index.js vendored
View file

@ -480,16 +480,16 @@ const commandExists = __webpack_require__(677);
const nodeCmd = __webpack_require__(428);
const nodeRsync = __webpack_require__(250);
const { REMOTE_HOST, REMOTE_USER, SSH_PRIVATE_KEY, DEPLOY_KEY_NAME, SOURCE, TARGET, ARGS, GITHUB_WORKSPACE, HOME } = process.env;
const { REMOTE_HOST, REMOTE_USER, REMOTE_PORT, SSH_PRIVATE_KEY, DEPLOY_KEY_NAME, SOURCE, TARGET, ARGS, GITHUB_WORKSPACE, HOME } = process.env;
console.log('GITHUB_WORKSPACE', GITHUB_WORKSPACE);
const sshDeploy = (() => {
const rsync = ({ privateKey, src, dest, args }) => {
const rsync = ({ privateKey, port, src, dest, args }) => {
console.log(`Starting Rsync Action: ${src} to ${dest}`);
try {
// RSYNC COMMAND
nodeRsync({ src, dest, args, privateKey, ssh: true, sshCmdArgs: ['-o StrictHostKeyChecking=no'], recursive: true }, (error, stdout, stderr, cmd) => {
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);
process.abort();
@ -509,14 +509,15 @@ const sshDeploy = (() => {
args,
host = 'localhost',
username,
privateKeyContent
privateKeyContent,
port
}) => {
validateRsync(() => {
const privateKey = addSshKey(privateKeyContent, DEPLOY_KEY_NAME ||'deploy_key');
const remoteDest = username + '@' + host + ':' + dest;
rsync({ privateKey, src, dest: remoteDest, args });
rsync({ privateKey, port, src, dest: remoteDest, args });
});
};
@ -616,6 +617,7 @@ const run = () => {
dest: TARGET || '/home/' + REMOTE_USER + '/',
args: [ARGS] || false,
host: REMOTE_HOST,
port: REMOTE_PORT || '22',
username: REMOTE_USER,
privateKeyContent: SSH_PRIVATE_KEY,
});