Compare commits

...

37 Commits

Author SHA1 Message Date
github-actions
b75a6aac49 chore(release): 2.2.3 [skip ci]
## [2.2.3](https://github.com/easingthemes/ssh-deploy/compare/v2.2.2...v2.2.3) (2021-05-27)

### Bug Fixes

* codeql yaml syntax update ([87ad671](87ad6713b5))
2021-05-27 21:20:23 +00:00
Dragan Filipović
a0be71d296 Merge pull request #52 from easingthemes/feature/codeql-fix
fix: codeql yaml syntax update
2021-05-27 23:19:39 +02:00
Dragan Filipovic
87ad6713b5 fix: codeql yaml syntax update 2021-05-27 23:16:38 +02:00
github-actions
b12dcbe93c chore(release): 2.2.2 [skip ci]
## [2.2.2](https://github.com/easingthemes/ssh-deploy/compare/v2.2.1...v2.2.2) (2021-05-27)

### Bug Fixes

* codeql build ([5e456a4](5e456a475a))
2021-05-27 21:14:04 +00:00
Dragan Filipović
c984a47bf5 Merge pull request #51 from easingthemes/feature/codeql-fix
fix: codeql build
2021-05-27 23:13:23 +02:00
Dragan Filipovic
5e456a475a fix: codeql build 2021-05-27 23:12:03 +02:00
github-actions
a9eda89ad7 chore(release): 2.2.1 [skip ci]
## [2.2.1](https://github.com/easingthemes/ssh-deploy/compare/v2.2.0...v2.2.1) (2021-05-27)

### Bug Fixes

* add package json auto updates ([ce56d75](ce56d75fc1))
2021-05-27 21:08:10 +00:00
Dragan Filipović
3cfa1cdc25 Merge pull request #50 from easingthemes/feature/release-npm-update
fix: add package json auto updates
2021-05-27 23:07:30 +02:00
Dragan Filipovic
ce56d75fc1 fix: add package json auto updates 2021-05-27 23:06:40 +02:00
github-actions
74b3a2aba4 chore(release): 2.2.0 [skip ci]
# [2.2.0](https://github.com/easingthemes/ssh-deploy/compare/v2.1.7...v2.2.0) (2021-05-27)

### Bug Fixes

* only=prod package json ([95f4dc8](95f4dc8069))
* replace i with ci ([50d1f57](50d1f576f9))
* update ncc ([20a0cae](20a0cae1ae))
* update plugins ([b2adc00](b2adc00c92))
* update plugins ([a50a999](a50a999528))

### Features

* add semantic-release-action ([ac3c9b5](ac3c9b51d5))
2021-05-27 21:00:10 +00:00
Dragan Filipović
77bfc8c169 Merge pull request #49 from easingthemes/feature/release-ci-update
feat: add semantic-release-action
2021-05-27 22:59:32 +02:00
Dragan Filipovic
ac3c9b51d5 feat: add semantic-release-action 2021-05-27 22:56:27 +02:00
Dragan Filipović
a0be893c82 Merge pull request #48 from easingthemes/feature/dependencies-update
Feature/dependencies update
2021-05-27 22:38:28 +02:00
Dragan Filipovic
50d1f576f9 fix: replace i with ci 2021-05-27 22:08:42 +02:00
Dragan Filipovic
20a0cae1ae fix: update ncc 2021-05-27 22:04:06 +02:00
Dragan Filipovic
95f4dc8069 fix: only=prod package json 2021-05-27 22:03:15 +02:00
Dragan Filipovic
b2adc00c92 fix: update plugins 2021-05-27 21:51:19 +02:00
Dragan Filipovic
a50a999528 fix: update plugins 2021-05-27 21:51:10 +02:00
github-actions
1242867d7a 2.1.9 2021-04-16 23:24:55 +00:00
Dragan Filipovic
33648ba2ca CI - test tags 2021-04-17 01:03:01 +02:00
github-actions
40a3789c05 2.1.8 2021-04-16 22:56:33 +00:00
github-actions
7e2c0f29d6 2.1.7 2021-04-16 22:41:08 +00:00
Dragan Filipovic
e9c43c6900 CI - use ci instead of install 2021-04-17 00:39:39 +02:00
Dragan Filipovic
9ae3c340cb CI add git user data 2021-04-17 00:36:22 +02:00
Dragan Filipovic
386c8766a0 CI - split git commands 2021-04-17 00:28:36 +02:00
Dragan Filipovic
130901534a CI - typo fix 2021-04-17 00:24:54 +02:00
Dragan Filipovic
8b977327bb CI - split git commands 2021-04-17 00:22:34 +02:00
Dragan Filipović
880f3b6b88 Merge pull request #43 from easingthemes/feature/CI-add-tag-action
Feature/ci add tag action
2021-04-17 00:18:03 +02:00
Dragan Filipovic
ec4a00fe02 CI - typo fix 2021-04-17 00:17:27 +02:00
Dragan Filipovic
a04c641775 CI - add steps names 2021-04-17 00:12:22 +02:00
Dragan Filipovic
9483c83d88 CI fix input vars 2021-04-17 00:08:19 +02:00
Dragan Filipovic
e41d593e15 CI add actions for build and tag 2021-04-17 00:06:00 +02:00
Dragan Filipović
9ab3993555 Merge pull request #35 from easingthemes/feature/RSYNC-exclude-option
RSYNC use excludeFirst instead of exclude
2021-03-24 18:50:40 +01:00
Dragan Filipovic
07265c8c95 RSYNC use excludeFirst instead of exclude 2021-03-24 18:48:12 +01:00
Dragan Filipović
a27b8667de Merge pull request #32 from peterkracik/master
Exclude folder parameter
2021-03-15 09:54:06 +01:00
Peter Kracik
2b38f7bf7a Added exclude parameter 2021-03-12 07:42:12 +01:00
Peter Kracik
cd3b869a28 Update action.yml 2021-03-12 07:26:41 +01:00
13 changed files with 1262 additions and 1028 deletions

31
.github/workflows/build.yml vendored Normal file
View File

@@ -0,0 +1,31 @@
name: Build
on:
push:
branches: [ '**' ]
pull_request:
branches: [ $default-branch ]
jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest]
node-version: [14.x]
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Setup Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- name: Install dependencies
run: npm ci
- name: Build Library
run: npm run build
- name: Run Tests
run: npm test --if-present

47
.github/workflows/codeql-analysis.yml vendored Normal file
View File

@@ -0,0 +1,47 @@
# For most projects, this workflow file will not need changing; you simply need
# to commit it to your repository.
#
# You may wish to alter this file to override the set of languages analyzed,
# or to provide custom queries or build logic.
#
# ******** NOTE ********
# We have attempted to detect the languages in your repository. Please check
# the `language` matrix defined below to confirm you have the correct set of
# supported CodeQL languages.
#
name: "CodeQL"
on:
push:
branches: [ main ]
pull_request:
# The branches below must be a subset of the branches above
branches: [ main ]
schedule:
- cron: '20 12 * * 0'
jobs:
analyze:
name: Analyze
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
language: [ 'javascript' ]
steps:
- name: Checkout
uses: actions/checkout@v2
# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v1
with:
languages: ${{ matrix.language }}
- run: |
npm ci
npm run build --if-present
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v1

43
.github/workflows/manual-release.yml vendored Normal file
View File

@@ -0,0 +1,43 @@
name: Manual Release
on:
workflow_dispatch:
inputs:
dryrun:
description: 'DryRUn'
required: true
default: 'false'
jobs:
release:
name: Test, Build and Release
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ ubuntu-latest ]
node-version: [ 14.x ]
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Setup Node.js
uses: actions/setup-node@v1
with:
node-version: ${{ matrix['node-version'] }}
- name: Install dependencies
run: npm ci
- name: Build Library
run: npm run build --if-present
- name: Run Tests
run: npm test --if-present
- name: Release
uses: cycjimmy/semantic-release-action@v2
with:
dry_run: ${{ github.event.inputs.dryrun == 'true' }}
extra_plugins: |
@semantic-release/changelog@3.0.0
@semantic-release/git
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GIT_AUTHOR_NAME: github-actions
GIT_AUTHOR_EMAIL: github-actions@github.com
GIT_COMMITTER_NAME: github-actions
GIT_COMMITTER_EMAIL: github-actions@github.com
CI: true

43
.github/workflows/release.yml vendored Normal file
View File

@@ -0,0 +1,43 @@
name: Release
on:
push:
branches:
- main
jobs:
release:
name: Test, Build and Release
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ ubuntu-latest ]
node-version: [ 14.x ]
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Setup Node.js
uses: actions/setup-node@v1
with:
node-version: ${{ matrix['node-version'] }}
- name: Install dependencies
run: npm ci
- name: Build Library
run: npm run build --if-present
- name: Run Tests
run: npm test --if-present
- name: Release
uses: cycjimmy/semantic-release-action@v2
with:
dry_run: false
extra_plugins: |
@semantic-release/changelog@3.0.0
@semantic-release/git
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GIT_AUTHOR_NAME: github-actions
GIT_AUTHOR_EMAIL: github-actions@github.com
GIT_COMMITTER_NAME: github-actions
GIT_COMMITTER_EMAIL: github-actions@github.com
CI: true

20
.releaserc Normal file
View File

@@ -0,0 +1,20 @@
{
"branches": ["main"],
"plugins": [
"@semantic-release/commit-analyzer",
"@semantic-release/release-notes-generator",
[
"@semantic-release/changelog",
{
"changelogFile": "docs/CHANGELOG.md"
}
],
"@semantic-release/npm",
[
"@semantic-release/git",
{
"assets": ["docs/CHANGELOG.md"]
}
]
]
}

View File

@@ -49,6 +49,10 @@ The source directory, path relative to `$GITHUB_WORKSPACE` root, eg: `dist/`
The target directory
##### 8. `EXCLUDE` (optional, default '')
path to exclude separated by `,`, ie: `/dist/, /node_modules/`
# Usage
!!! Please use latest version, Readme file is just an example, eg: ssh-deploy@v2.1.5
@@ -63,6 +67,7 @@ The target directory
REMOTE_HOST: ${{ secrets.REMOTE_HOST }}
REMOTE_USER: ${{ secrets.REMOTE_USER }}
TARGET: ${{ secrets.REMOTE_TARGET }}
EXCLUDE: "/dist/, /node_modules/"
```
# Example usage in workflow
@@ -96,6 +101,7 @@ jobs:
REMOTE_HOST: ${{ secrets.REMOTE_HOST }}
REMOTE_USER: ${{ secrets.REMOTE_USER }}
TARGET: ${{ secrets.REMOTE_TARGET }}
EXCLUDE: "/dist/, /node_modules/"
```
## Disclaimer

View File

@@ -27,6 +27,10 @@ inputs:
description: "Arguments to pass to rsync"
required: false
default: "-rltgoDzvO"
EXCLUDE:
description: "An array of folder to exclude"
required: false
default: ""
outputs:
status:
description: "Status"

588
dist/index.js vendored
View File

@@ -1,111 +1,25 @@
#!/usr/bin/env node
module.exports =
/******/ (function(modules, runtime) { // webpackBootstrap
/******/ "use strict";
/******/ // The module cache
/******/ var installedModules = {};
/******/
/******/ // The require function
/******/ function __webpack_require__(moduleId) {
/******/
/******/ // Check if module is in cache
/******/ if(installedModules[moduleId]) {
/******/ return installedModules[moduleId].exports;
/******/ }
/******/ // Create a new module (and put it into the cache)
/******/ var module = installedModules[moduleId] = {
/******/ i: moduleId,
/******/ l: false,
/******/ exports: {}
/******/ };
/******/
/******/ // Execute the module function
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
/******/
/******/ // Flag the module as loaded
/******/ module.l = true;
/******/
/******/ // Return the exports of the module
/******/ return module.exports;
/******/ }
/******/
/******/
/******/ __webpack_require__.ab = __dirname + "/";
/******/
/******/ // the startup function
/******/ function startup() {
/******/ // Load entry module and return exports
/******/ return __webpack_require__(676);
/******/ };
/******/
/******/ // run startup
/******/ return startup();
/******/ })
/************************************************************************/
/******/ ({
/******/ (() => { // webpackBootstrap
/******/ var __webpack_modules__ = ({
/***/ 129:
/***/ (function(module) {
/***/ 569:
/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
module.exports = require("child_process");
/***/ }),
/***/ 197:
/***/ (function(module, __unusedexports, __webpack_require__) {
const { existsSync, mkdirSync, writeFileSync } = __webpack_require__(747);
const {
GITHUB_WORKSPACE
} = process.env;
const validateDir = (dir) => {
if (!existsSync(dir)) {
console.log(`[SSH] Creating ${dir} dir in `, GITHUB_WORKSPACE);
mkdirSync(dir);
console.log('✅ [SSH] dir created.');
} else {
console.log(`[SSH] ${dir} dir exist`);
}
};
const validateFile = (filePath) => {
if (!existsSync(filePath)) {
console.log(`[SSH] Creating ${filePath} file in `, GITHUB_WORKSPACE);
try {
writeFileSync(filePath, '', {
encoding: 'utf8',
mode: 0o600
});
console.log('✅ [SSH] file created.');
} catch (e) {
console.error('⚠️ [SSH] writeFileSync error', filePath, e.message);
process.abort();
}
} else {
console.log(`[SSH] ${filePath} file exist`);
}
};
module.exports = {
validateDir,
validateFile
};
module.exports = __nccwpck_require__(325);
/***/ }),
/***/ 243:
/***/ (function(module, __unusedexports, __webpack_require__) {
/***/ 325:
/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
"use strict";
var exec = __webpack_require__(129).exec;
var execSync = __webpack_require__(129).execSync;
var fs = __webpack_require__(747);
var path = __webpack_require__(622);
var exec = __nccwpck_require__(129).exec;
var execSync = __nccwpck_require__(129).execSync;
var fs = __nccwpck_require__(747);
var path = __nccwpck_require__(622);
var access = fs.access;
var accessSync = fs.accessSync;
var constants = fs.constants || fs;
@@ -164,7 +78,8 @@ var commandExistsUnix = function(commandName, cleanedCommandName, callback) {
}
var commandExistsWindows = function(commandName, cleanedCommandName, callback) {
if (/[\x00-\x1f<>:"\|\?\*]/.test(commandName)) {
// Regex from Julio from: https://stackoverflow.com/questions/51494579/regex-windows-path-validator
if (!(/^(?!(?:.*\s|.*\.|\W+)$)(?:[a-zA-Z]:)?(?:(?:[^<>:"\|\?\*\n])+(?:\/\/|\/|\\\\|\\)?)+$/m.test(commandName))) {
callback(null, false);
return;
}
@@ -195,7 +110,8 @@ var commandExistsUnixSync = function(commandName, cleanedCommandName) {
}
var commandExistsWindowsSync = function(commandName, cleanedCommandName, callback) {
if (/[\x00-\x1f<>:"\|\?\*]/.test(commandName)) {
// Regex from Julio from: https://stackoverflow.com/questions/51494579/regex-windows-path-validator
if (!(/^(?!(?:.*\s|.*\.|\W+)$)(?:[a-zA-Z]:)?(?:(?:[^<>:"\|\?\*\n])+(?:\/\/|\/|\\\\|\\)?)+$/m.test(commandName))) {
return false;
}
try {
@@ -259,14 +175,66 @@ module.exports.sync = function(commandName) {
/***/ }),
/***/ 250:
/***/ (function(module, __unusedexports, __webpack_require__) {
/***/ 748:
/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
const { exec, execSync } = __nccwpck_require__(129);
const commandline={
run:runCommand,
runSync:runSync,
//will be deprecated soon as run is now the same.
get:runCommand,
};
function runCommand(command,callback){
return exec(
command,
(
function(){
return function(err,data,stderr){
if(!callback)
return;
callback(err, data, stderr);
}
}
)(callback)
);
}
function runSync(command){
try {
return {
data: execSync(command).toString(),
err: null,
stderr: null
}
}
catch (error) {
return {
data: null,
err: error.stderr.toString(),
stderr: error.stderr.toString()
}
}
}
module.exports=commandline;
/***/ }),
/***/ 898:
/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
"use strict";
var spawn = __webpack_require__(129).spawn
var util = __webpack_require__(669)
var spawn = __nccwpck_require__(129).spawn
var util = __nccwpck_require__(669)
var escapeSpaces = function(path) {
if (typeof path === 'string') {
@@ -463,100 +431,55 @@ module.exports = function(options, callback) {
/***/ }),
/***/ 428:
/***/ (function(module, __unusedexports, __webpack_require__) {
/***/ 505:
/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
var exec = __webpack_require__(129).exec;
var commandline={
get:getString,
run:runCommand
};
function runCommand(command){
//return refrence to the child process
return exec(
command
);
}
function getString(command,callback){
//return refrence to the child process
return exec(
command,
(
function(){
return function(err,data,stderr){
if(!callback)
return;
callback(err, data, stderr);
}
}
)(callback)
);
}
module.exports=commandline;
/***/ }),
/***/ 613:
/***/ (function(module, __unusedexports, __webpack_require__) {
const { writeFileSync } = __webpack_require__(747);
const { join } = __webpack_require__(622);
const { existsSync, mkdirSync, writeFileSync } = __nccwpck_require__(747);
const {
validateDir,
validateFile
} = __webpack_require__(197);
const {
HOME
GITHUB_WORKSPACE
} = process.env;
const addSshKey = (key, name) => {
const sshDir = join(HOME || __dirname, '.ssh');
const filePath = join(sshDir, name);
validateDir(sshDir);
validateFile(`${sshDir}/known_hosts`);
try {
writeFileSync(filePath, key, {
encoding: 'utf8',
mode: 0o600
});
} catch (e) {
console.error('⚠️ writeFileSync error', filePath, e.message);
process.abort();
const validateDir = (dir) => {
if (!existsSync(dir)) {
console.log(`[SSH] Creating ${dir} dir in `, GITHUB_WORKSPACE);
mkdirSync(dir);
console.log('✅ [SSH] dir created.');
} else {
console.log(`[SSH] ${dir} dir exist`);
}
};
console.log('✅ Ssh key added to `.ssh` dir ', filePath);
return filePath;
const validateFile = (filePath) => {
if (!existsSync(filePath)) {
console.log(`[SSH] Creating ${filePath} file in `, GITHUB_WORKSPACE);
try {
writeFileSync(filePath, '', {
encoding: 'utf8',
mode: 0o600
});
console.log('✅ [SSH] file created.');
} catch (e) {
console.error('⚠️ [SSH] writeFileSync error', filePath, e.message);
process.abort();
}
} else {
console.log(`[SSH] ${filePath} file exist`);
}
};
module.exports = {
addSshKey
}
validateDir,
validateFile
};
/***/ }),
/***/ 622:
/***/ (function(module) {
/***/ 229:
/***/ ((module) => {
module.exports = require("path");
/***/ }),
/***/ 659:
/***/ (function(module) {
const inputNames = ['REMOTE_HOST', 'REMOTE_USER', 'REMOTE_PORT', 'SSH_PRIVATE_KEY', 'DEPLOY_KEY_NAME', 'SOURCE', 'TARGET', 'ARGS'];
const inputNames = ['REMOTE_HOST', 'REMOTE_USER', 'REMOTE_PORT', 'SSH_PRIVATE_KEY', 'DEPLOY_KEY_NAME', 'SOURCE', 'TARGET', 'ARGS', 'EXCLUDE'];
const inputs = {
GITHUB_WORKSPACE: process.env.GITHUB_WORKSPACE
@@ -571,107 +494,11 @@ module.exports = inputs;
/***/ }),
/***/ 669:
/***/ (function(module) {
/***/ 447:
/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
module.exports = require("util");
/***/ }),
/***/ 676:
/***/ (function(__unusedmodule, __unusedexports, __webpack_require__) {
const nodeRsync = __webpack_require__(250);
const { validateRsync, validateInputs } = __webpack_require__(735);
const { addSshKey } = __webpack_require__(613);
const {
REMOTE_HOST, REMOTE_USER,
REMOTE_PORT, SSH_PRIVATE_KEY, DEPLOY_KEY_NAME,
SOURCE, TARGET, ARGS,
GITHUB_WORKSPACE
} = __webpack_require__(659);
const defaultOptions = {
ssh: true,
sshCmdArgs: ['-o StrictHostKeyChecking=no'],
recursive: true
};
console.log('[general] GITHUB_WORKSPACE: ', GITHUB_WORKSPACE);
const sshDeploy = (() => {
const rsync = ({ privateKey, port, src, dest, args }) => {
console.log(`[Rsync] Starting Rsync Action: ${src} to ${dest}`);
try {
// RSYNC COMMAND
nodeRsync({
src, dest, args, privateKey, port, ...defaultOptions
}, (error, stdout, stderr, cmd) => {
if (error) {
console.error('⚠️ [Rsync] error: ', error.message);
console.log('⚠️ [Rsync] stderr: ', stderr);
console.log('⚠️ [Rsync] stdout: ', stdout);
console.log('⚠️ [Rsync] cmd: ', cmd);
process.abort();
} else {
console.log('✅ [Rsync] finished.', stdout);
}
});
} catch (err) {
console.error('⚠️ [Rsync] command error: ', err.message, err.stack);
process.abort();
}
};
const init = ({ src, dest, args, host = 'localhost', port, username, privateKeyContent }) => {
validateRsync(() => {
const privateKey = addSshKey(privateKeyContent, DEPLOY_KEY_NAME || 'deploy_key');
const remoteDest = `${username}@${host}:${dest}`;
rsync({ privateKey, port, src, dest: remoteDest, args });
});
};
return {
init
};
})();
const run = () => {
validateInputs({ SSH_PRIVATE_KEY, REMOTE_HOST, REMOTE_USER });
sshDeploy.init({
src: `${GITHUB_WORKSPACE}/${SOURCE || ''}`,
dest: TARGET || `/home/${REMOTE_USER}/`,
args: ARGS ? [ARGS] : ['-rltgoDzvO'],
host: REMOTE_HOST,
port: REMOTE_PORT || '22',
username: REMOTE_USER,
privateKeyContent: SSH_PRIVATE_KEY
});
};
run();
/***/ }),
/***/ 677:
/***/ (function(module, __unusedexports, __webpack_require__) {
module.exports = __webpack_require__(243);
/***/ }),
/***/ 735:
/***/ (function(module, __unusedexports, __webpack_require__) {
const { sync: commandExists } = __webpack_require__(677);
const { get: nodeCmd } = __webpack_require__(428);
const { sync: commandExists } = __nccwpck_require__(569);
const { get: nodeCmd } = __nccwpck_require__(748);
const validateRsync = (callback = () => {}) => {
const rsyncCli = commandExists('rsync');
@@ -720,11 +547,200 @@ module.exports = {
/***/ }),
/***/ 747:
/***/ (function(module) {
/***/ 822:
/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {
module.exports = require("fs");
const { writeFileSync } = __nccwpck_require__(747);
const { join } = __nccwpck_require__(622);
const {
validateDir,
validateFile
} = __nccwpck_require__(505);
const {
HOME
} = process.env;
const addSshKey = (key, name) => {
const sshDir = join(HOME || __dirname, '.ssh');
const filePath = join(sshDir, name);
validateDir(sshDir);
validateFile(`${sshDir}/known_hosts`);
try {
writeFileSync(filePath, key, {
encoding: 'utf8',
mode: 0o600
});
} catch (e) {
console.error('⚠️ writeFileSync error', filePath, e.message);
process.abort();
}
console.log('✅ Ssh key added to `.ssh` dir ', filePath);
return filePath;
};
module.exports = {
addSshKey
}
/***/ }),
/***/ 129:
/***/ ((module) => {
"use strict";
module.exports = require("child_process");;
/***/ }),
/***/ 747:
/***/ ((module) => {
"use strict";
module.exports = require("fs");;
/***/ }),
/***/ 622:
/***/ ((module) => {
"use strict";
module.exports = require("path");;
/***/ }),
/***/ 669:
/***/ ((module) => {
"use strict";
module.exports = require("util");;
/***/ })
/******/ });
/******/ });
/************************************************************************/
/******/ // The module cache
/******/ var __webpack_module_cache__ = {};
/******/
/******/ // The require function
/******/ function __nccwpck_require__(moduleId) {
/******/ // Check if module is in cache
/******/ var cachedModule = __webpack_module_cache__[moduleId];
/******/ if (cachedModule !== undefined) {
/******/ return cachedModule.exports;
/******/ }
/******/ // Create a new module (and put it into the cache)
/******/ var module = __webpack_module_cache__[moduleId] = {
/******/ // no module.id needed
/******/ // no module.loaded needed
/******/ exports: {}
/******/ };
/******/
/******/ // Execute the module function
/******/ var threw = true;
/******/ try {
/******/ __webpack_modules__[moduleId](module, module.exports, __nccwpck_require__);
/******/ threw = false;
/******/ } finally {
/******/ if(threw) delete __webpack_module_cache__[moduleId];
/******/ }
/******/
/******/ // Return the exports of the module
/******/ return module.exports;
/******/ }
/******/
/************************************************************************/
/******/ /* webpack/runtime/compat */
/******/
/******/ if (typeof __nccwpck_require__ !== 'undefined') __nccwpck_require__.ab = __dirname + "/";/************************************************************************/
var __webpack_exports__ = {};
// This entry need to be wrapped in an IIFE because it need to be isolated against other modules in the chunk.
(() => {
const nodeRsync = __nccwpck_require__(898);
const { validateRsync, validateInputs } = __nccwpck_require__(447);
const { addSshKey } = __nccwpck_require__(822);
const {
REMOTE_HOST, REMOTE_USER,
REMOTE_PORT, SSH_PRIVATE_KEY, DEPLOY_KEY_NAME,
SOURCE, TARGET, ARGS, EXCLUDE,
GITHUB_WORKSPACE
} = __nccwpck_require__(229);
const defaultOptions = {
ssh: true,
sshCmdArgs: ['-o StrictHostKeyChecking=no'],
recursive: true
};
console.log('[general] GITHUB_WORKSPACE: ', GITHUB_WORKSPACE);
const sshDeploy = (() => {
const rsync = ({ privateKey, port, src, dest, args, exclude }) => {
console.log(`[Rsync] Starting Rsync Action: ${src} to ${dest}`);
if (exclude) console.log(`[Rsync] exluding folders ${exclude}`);
try {
// RSYNC COMMAND
nodeRsync({
src, dest, args, privateKey, port, excludeFirst: exclude, ...defaultOptions
}, (error, stdout, stderr, cmd) => {
if (error) {
console.error('⚠️ [Rsync] error: ', error.message);
console.log('⚠️ [Rsync] stderr: ', stderr);
console.log('⚠️ [Rsync] stdout: ', stdout);
console.log('⚠️ [Rsync] cmd: ', cmd);
process.abort();
} else {
console.log('✅ [Rsync] finished.', stdout);
}
});
} catch (err) {
console.error('⚠️ [Rsync] command error: ', err.message, err.stack);
process.abort();
}
};
const init = ({ src, dest, args, host = 'localhost', port, username, privateKeyContent, exclude = [] }) => {
validateRsync(() => {
const privateKey = addSshKey(privateKeyContent, DEPLOY_KEY_NAME || 'deploy_key');
const remoteDest = `${username}@${host}:${dest}`;
rsync({ privateKey, port, src, dest: remoteDest, args, exclude });
});
};
return {
init
};
})();
const run = () => {
validateInputs({ SSH_PRIVATE_KEY, REMOTE_HOST, REMOTE_USER });
sshDeploy.init({
src: `${GITHUB_WORKSPACE}/${SOURCE || ''}`,
dest: TARGET || `/home/${REMOTE_USER}/`,
args: ARGS ? [ARGS] : ['-rltgoDzvO'],
host: REMOTE_HOST,
port: REMOTE_PORT || '22',
username: REMOTE_USER,
privateKeyContent: SSH_PRIVATE_KEY,
exclude: (EXCLUDE || '').split(',').map((item) => item.trim()) // split by comma and trim whitespace
});
};
run();
})();
module.exports = __webpack_exports__;
/******/ })()
;

36
docs/CHANGELOG.md Normal file
View File

@@ -0,0 +1,36 @@
## [2.2.3](https://github.com/easingthemes/ssh-deploy/compare/v2.2.2...v2.2.3) (2021-05-27)
### Bug Fixes
* codeql yaml syntax update ([87ad671](https://github.com/easingthemes/ssh-deploy/commit/87ad6713b53d454bd7ad6c4576cea7b2e3e2f4f3))
## [2.2.2](https://github.com/easingthemes/ssh-deploy/compare/v2.2.1...v2.2.2) (2021-05-27)
### Bug Fixes
* codeql build ([5e456a4](https://github.com/easingthemes/ssh-deploy/commit/5e456a475a15096d08ccd2aff2734b3f1250b308))
## [2.2.1](https://github.com/easingthemes/ssh-deploy/compare/v2.2.0...v2.2.1) (2021-05-27)
### Bug Fixes
* add package json auto updates ([ce56d75](https://github.com/easingthemes/ssh-deploy/commit/ce56d75fc1b62a99d72ffba70dcb24fcc3b6b3df))
# [2.2.0](https://github.com/easingthemes/ssh-deploy/compare/v2.1.7...v2.2.0) (2021-05-27)
### Bug Fixes
* only=prod package json ([95f4dc8](https://github.com/easingthemes/ssh-deploy/commit/95f4dc8069045c1f5f726e00cb519b46e4f14267))
* replace i with ci ([50d1f57](https://github.com/easingthemes/ssh-deploy/commit/50d1f576f95c0d7e8ce99fb1b2ab68b2594973e5))
* update ncc ([20a0cae](https://github.com/easingthemes/ssh-deploy/commit/20a0cae1ae81bcc430507363e800342976307a81))
* update plugins ([b2adc00](https://github.com/easingthemes/ssh-deploy/commit/b2adc00c92f129aef41ae46441411c2bebc0dbe4))
* update plugins ([a50a999](https://github.com/easingthemes/ssh-deploy/commit/a50a999528b503846cc7fdf26210f710bd95565a))
### Features
* add semantic-release-action ([ac3c9b5](https://github.com/easingthemes/ssh-deploy/commit/ac3c9b51d5cb52f4add40e2fc2dcc5e970153afc))

1437
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -1,18 +1,19 @@
{
"name": "ssh-deploy",
"version": "2.1.5",
"description": "This GitHub Action deploys specific directory from `GITHUB_WORKSPACE` to a folder on a server via rsync over ssh.",
"version": "2.1.9",
"private": true,
"description": "Fast NodeJS action to deploy specific directory from `GITHUB_WORKSPACE` to a server via rsync over ssh.",
"main": "src/index.js",
"dependencies": {
"command-exists": "1.2.8",
"node-cmd": "3.0.0",
"command-exists": "1.2.9",
"node-cmd": "4.0.0",
"rsyncwrapper": "3.0.1"
},
"devDependencies": {
"@zeit/ncc": "^0.20.5",
"eslint": "^6.8.0",
"eslint-config-airbnb-base": "^14.1.0",
"eslint-plugin-import": "^2.20.2"
"@vercel/ncc": "^0.28.6",
"eslint": "^7.27.0",
"eslint-config-airbnb-base": "^14.2.1",
"eslint-plugin-import": "^2.23.3"
},
"scripts": {
"build": "npm run lint && ncc build ./src/index.js -o dist",
@@ -29,7 +30,7 @@
"rsync"
],
"author": "Dragan Filipovic",
"license": "ISC",
"license": "MIT",
"bugs": {
"url": "https://github.com/easingthemes/ssh-deploy/issues"
},

View File

@@ -7,7 +7,7 @@ const { addSshKey } = require('./sshKey');
const {
REMOTE_HOST, REMOTE_USER,
REMOTE_PORT, SSH_PRIVATE_KEY, DEPLOY_KEY_NAME,
SOURCE, TARGET, ARGS,
SOURCE, TARGET, ARGS, EXCLUDE,
GITHUB_WORKSPACE
} = require('./inputs');
@@ -20,13 +20,14 @@ const defaultOptions = {
console.log('[general] GITHUB_WORKSPACE: ', GITHUB_WORKSPACE);
const sshDeploy = (() => {
const rsync = ({ privateKey, port, src, dest, args }) => {
const rsync = ({ privateKey, port, src, dest, args, exclude }) => {
console.log(`[Rsync] Starting Rsync Action: ${src} to ${dest}`);
if (exclude) console.log(`[Rsync] exluding folders ${exclude}`);
try {
// RSYNC COMMAND
nodeRsync({
src, dest, args, privateKey, port, ...defaultOptions
src, dest, args, privateKey, port, excludeFirst: exclude, ...defaultOptions
}, (error, stdout, stderr, cmd) => {
if (error) {
console.error('⚠️ [Rsync] error: ', error.message);
@@ -44,12 +45,12 @@ const sshDeploy = (() => {
}
};
const init = ({ src, dest, args, host = 'localhost', port, username, privateKeyContent }) => {
const init = ({ src, dest, args, host = 'localhost', port, username, privateKeyContent, exclude = [] }) => {
validateRsync(() => {
const privateKey = addSshKey(privateKeyContent, DEPLOY_KEY_NAME || 'deploy_key');
const remoteDest = `${username}@${host}:${dest}`;
rsync({ privateKey, port, src, dest: remoteDest, args });
rsync({ privateKey, port, src, dest: remoteDest, args, exclude });
});
};
@@ -68,7 +69,8 @@ const run = () => {
host: REMOTE_HOST,
port: REMOTE_PORT || '22',
username: REMOTE_USER,
privateKeyContent: SSH_PRIVATE_KEY
privateKeyContent: SSH_PRIVATE_KEY,
exclude: (EXCLUDE || '').split(',').map((item) => item.trim()) // split by comma and trim whitespace
});
};

View File

@@ -1,4 +1,4 @@
const inputNames = ['REMOTE_HOST', 'REMOTE_USER', 'REMOTE_PORT', 'SSH_PRIVATE_KEY', 'DEPLOY_KEY_NAME', 'SOURCE', 'TARGET', 'ARGS'];
const inputNames = ['REMOTE_HOST', 'REMOTE_USER', 'REMOTE_PORT', 'SSH_PRIVATE_KEY', 'DEPLOY_KEY_NAME', 'SOURCE', 'TARGET', 'ARGS', 'EXCLUDE'];
const inputs = {
GITHUB_WORKSPACE: process.env.GITHUB_WORKSPACE