mirror of
https://github.com/easingthemes/ssh-deploy.git
synced 2024-11-19 08:08:05 +08:00
Compare commits
11 Commits
v2.1.4-rc.
...
v2.1.6-rc.
Author | SHA1 | Date | |
---|---|---|---|
|
a27b8667de | ||
|
2b38f7bf7a | ||
|
cd3b869a28 | ||
|
191986574c | ||
|
d41b136666 | ||
|
1ac1bcb558 | ||
|
c14eb85faf | ||
|
2bc5e10d4d | ||
|
4f928a3efc | ||
|
aac4cbf0db | ||
|
4042d3876f |
12
README.md
12
README.md
@@ -49,11 +49,17 @@ 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
|
||||
|
||||
```
|
||||
- name: Deploy to Staging server
|
||||
uses: easingthemes/ssh-deploy@v2.0.7
|
||||
uses: easingthemes/ssh-deploy@v2.1.5
|
||||
env:
|
||||
SSH_PRIVATE_KEY: ${{ secrets.SERVER_SSH_KEY }}
|
||||
ARGS: "-rltgoDzvO"
|
||||
@@ -61,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
|
||||
@@ -86,7 +93,7 @@ jobs:
|
||||
- name: Run build task
|
||||
run: npm run build --if-present
|
||||
- name: Deploy to Server
|
||||
uses: easingthemes/ssh-deploy@v2.1.1
|
||||
uses: easingthemes/ssh-deploy@v2.1.5
|
||||
env:
|
||||
SSH_PRIVATE_KEY: ${{ secrets.SERVER_SSH_KEY }}
|
||||
ARGS: "-rltgoDzvO --delete"
|
||||
@@ -94,6 +101,7 @@ jobs:
|
||||
REMOTE_HOST: ${{ secrets.REMOTE_HOST }}
|
||||
REMOTE_USER: ${{ secrets.REMOTE_USER }}
|
||||
TARGET: ${{ secrets.REMOTE_TARGET }}
|
||||
EXCLUDE: "/dist/, /node_modules/"
|
||||
```
|
||||
|
||||
## Disclaimer
|
||||
|
@@ -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"
|
||||
|
20
dist/index.js
vendored
20
dist/index.js
vendored
@@ -556,7 +556,7 @@ 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
|
||||
@@ -589,7 +589,7 @@ const { addSshKey } = __webpack_require__(613);
|
||||
const {
|
||||
REMOTE_HOST, REMOTE_USER,
|
||||
REMOTE_PORT, SSH_PRIVATE_KEY, DEPLOY_KEY_NAME,
|
||||
SOURCE, TARGET, ARGS,
|
||||
SOURCE, TARGET, ARGS, EXCLUDE,
|
||||
GITHUB_WORKSPACE
|
||||
} = __webpack_require__(659);
|
||||
|
||||
@@ -602,13 +602,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, exclude, ...defaultOptions
|
||||
}, (error, stdout, stderr, cmd) => {
|
||||
if (error) {
|
||||
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(() => {
|
||||
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 });
|
||||
});
|
||||
};
|
||||
|
||||
@@ -650,7 +651,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
|
||||
});
|
||||
};
|
||||
|
||||
@@ -707,7 +709,7 @@ const validateInputs = (inputs) => {
|
||||
});
|
||||
|
||||
if (validInputs.length !== inputKeys.length) {
|
||||
console.error(`⚠️ [INPUTS] Inputs not valid, aborting ...`);
|
||||
console.error('⚠️ [INPUTS] Inputs not valid, aborting ...');
|
||||
process.abort();
|
||||
}
|
||||
};
|
||||
@@ -715,7 +717,7 @@ const validateInputs = (inputs) => {
|
||||
module.exports = {
|
||||
validateRsync,
|
||||
validateInputs
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/***/ }),
|
||||
|
2070
package-lock.json
generated
2070
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "ssh-deploy",
|
||||
"version": "2.1.4-rc.1",
|
||||
"version": "2.1.5",
|
||||
"description": "This GitHub Action deploys specific directory from `GITHUB_WORKSPACE` to a folder on a server via rsync over ssh.",
|
||||
"main": "src/index.js",
|
||||
"dependencies": {
|
||||
|
14
src/index.js
14
src/index.js
@@ -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, 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
|
||||
});
|
||||
};
|
||||
|
||||
|
@@ -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
|
||||
|
@@ -35,7 +35,7 @@ const validateInputs = (inputs) => {
|
||||
});
|
||||
|
||||
if (validInputs.length !== inputKeys.length) {
|
||||
console.error(`⚠️ [INPUTS] Inputs not valid, aborting ...`);
|
||||
console.error('⚠️ [INPUTS] Inputs not valid, aborting ...');
|
||||
process.abort();
|
||||
}
|
||||
};
|
||||
@@ -43,4 +43,4 @@ const validateInputs = (inputs) => {
|
||||
module.exports = {
|
||||
validateRsync,
|
||||
validateInputs
|
||||
}
|
||||
};
|
||||
|
Reference in New Issue
Block a user