Compare commits

..

16 Commits

Author SHA1 Message Date
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
9 changed files with 2151 additions and 17 deletions

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

@@ -0,0 +1,27 @@
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:
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- run: npm i
- run: npm run lint
- run: npm run build

View File

@@ -0,0 +1,33 @@
name: Release
on:
workflow_dispatch:
inputs:
tag:
description: '<newversion> | major | minor | patch'
required: true
default: 'patch'
jobs:
checkout:
name: checkout
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- run: |
git config user.name github-actions
git config user.email github-actions@github.com
- name: Setup NodeJS and run build
uses: actions/setup-node@v1
with:
node-version: 12
- run: |
npm ci
npm run lint
npm run build
- name: Setup version
if: ${{ github.event.inputs.tag != '' }}
run: |
npm version ${{ github.event.inputs.tag }}
git push
- name: Add tag
run: git tag -a v${{ github.event.inputs.tag }} -m "v${{ github.event.inputs.tag }}"

View File

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

View File

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

16
dist/index.js vendored
View File

@@ -556,7 +556,7 @@ module.exports = require("path");
/***/ 659: /***/ 659:
/***/ (function(module) { /***/ (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 = { const inputs = {
GITHUB_WORKSPACE: process.env.GITHUB_WORKSPACE GITHUB_WORKSPACE: process.env.GITHUB_WORKSPACE
@@ -589,7 +589,7 @@ const { addSshKey } = __webpack_require__(613);
const { const {
REMOTE_HOST, REMOTE_USER, REMOTE_HOST, REMOTE_USER,
REMOTE_PORT, SSH_PRIVATE_KEY, DEPLOY_KEY_NAME, REMOTE_PORT, SSH_PRIVATE_KEY, DEPLOY_KEY_NAME,
SOURCE, TARGET, ARGS, SOURCE, TARGET, ARGS, EXCLUDE,
GITHUB_WORKSPACE GITHUB_WORKSPACE
} = __webpack_require__(659); } = __webpack_require__(659);
@@ -602,13 +602,14 @@ const defaultOptions = {
console.log('[general] GITHUB_WORKSPACE: ', GITHUB_WORKSPACE); console.log('[general] GITHUB_WORKSPACE: ', GITHUB_WORKSPACE);
const sshDeploy = (() => { 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}`); console.log(`[Rsync] Starting Rsync Action: ${src} to ${dest}`);
if (exclude) console.log(`[Rsync] exluding folders ${exclude}`);
try { try {
// RSYNC COMMAND // RSYNC COMMAND
nodeRsync({ nodeRsync({
src, dest, args, privateKey, port, ...defaultOptions src, dest, args, privateKey, port, excludeFirst: exclude, ...defaultOptions
}, (error, stdout, stderr, cmd) => { }, (error, stdout, stderr, cmd) => {
if (error) { if (error) {
console.error('⚠️ [Rsync] error: ', error.message); console.error('⚠️ [Rsync] error: ', error.message);
@@ -626,12 +627,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(() => { validateRsync(() => {
const privateKey = addSshKey(privateKeyContent, DEPLOY_KEY_NAME || 'deploy_key'); const privateKey = addSshKey(privateKeyContent, DEPLOY_KEY_NAME || 'deploy_key');
const remoteDest = `${username}@${host}:${dest}`; const remoteDest = `${username}@${host}:${dest}`;
rsync({ privateKey, port, src, dest: remoteDest, args }); rsync({ privateKey, port, src, dest: remoteDest, args, exclude });
}); });
}; };
@@ -650,7 +651,8 @@ const run = () => {
host: REMOTE_HOST, host: REMOTE_HOST,
port: REMOTE_PORT || '22', port: REMOTE_PORT || '22',
username: REMOTE_USER, username: REMOTE_USER,
privateKeyContent: SSH_PRIVATE_KEY privateKeyContent: SSH_PRIVATE_KEY,
exclude: (EXCLUDE || '').split(',').map((item) => item.trim()) // split by comma and trim whitespace
}); });
}; };

2064
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -1,6 +1,6 @@
{ {
"name": "ssh-deploy", "name": "ssh-deploy",
"version": "2.1.5", "version": "2.1.7",
"description": "This GitHub Action deploys specific directory from `GITHUB_WORKSPACE` to a folder on a server via rsync over ssh.", "description": "This GitHub Action deploys specific directory from `GITHUB_WORKSPACE` to a folder on a server via rsync over ssh.",
"main": "src/index.js", "main": "src/index.js",
"dependencies": { "dependencies": {

View File

@@ -7,7 +7,7 @@ const { addSshKey } = require('./sshKey');
const { const {
REMOTE_HOST, REMOTE_USER, REMOTE_HOST, REMOTE_USER,
REMOTE_PORT, SSH_PRIVATE_KEY, DEPLOY_KEY_NAME, REMOTE_PORT, SSH_PRIVATE_KEY, DEPLOY_KEY_NAME,
SOURCE, TARGET, ARGS, SOURCE, TARGET, ARGS, EXCLUDE,
GITHUB_WORKSPACE GITHUB_WORKSPACE
} = require('./inputs'); } = require('./inputs');
@@ -20,13 +20,14 @@ const defaultOptions = {
console.log('[general] GITHUB_WORKSPACE: ', GITHUB_WORKSPACE); console.log('[general] GITHUB_WORKSPACE: ', GITHUB_WORKSPACE);
const sshDeploy = (() => { 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}`); console.log(`[Rsync] Starting Rsync Action: ${src} to ${dest}`);
if (exclude) console.log(`[Rsync] exluding folders ${exclude}`);
try { try {
// RSYNC COMMAND // RSYNC COMMAND
nodeRsync({ nodeRsync({
src, dest, args, privateKey, port, ...defaultOptions src, dest, args, privateKey, port, excludeFirst: exclude, ...defaultOptions
}, (error, stdout, stderr, cmd) => { }, (error, stdout, stderr, cmd) => {
if (error) { if (error) {
console.error('⚠️ [Rsync] error: ', error.message); 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(() => { validateRsync(() => {
const privateKey = addSshKey(privateKeyContent, DEPLOY_KEY_NAME || 'deploy_key'); const privateKey = addSshKey(privateKeyContent, DEPLOY_KEY_NAME || 'deploy_key');
const remoteDest = `${username}@${host}:${dest}`; 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, host: REMOTE_HOST,
port: REMOTE_PORT || '22', port: REMOTE_PORT || '22',
username: REMOTE_USER, 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 = { const inputs = {
GITHUB_WORKSPACE: process.env.GITHUB_WORKSPACE GITHUB_WORKSPACE: process.env.GITHUB_WORKSPACE