mirror of
https://github.com/easingthemes/ssh-deploy.git
synced 2024-11-19 08:08:05 +08:00
Compare commits
40 Commits
v4
...
e923ff605c
Author | SHA1 | Date | |
---|---|---|---|
|
e923ff605c | ||
|
cf583aab4f | ||
|
3405be3b42 | ||
|
e7f0312c8c | ||
|
3884c8554f | ||
|
168ff9f4b8 | ||
|
98025d680e | ||
|
88cc5ade97 | ||
|
ad7eefb5ae | ||
|
54dca654be | ||
|
b0ee052eb0 | ||
|
2fbb06015d | ||
|
51b2009841 | ||
|
530a3691f2 | ||
|
509caf1bb9 | ||
|
54f8b6c60b | ||
|
d9d134f8e5 | ||
|
e7b2312bc9 | ||
|
f0c02fb2a5 | ||
|
ae4970d4cf | ||
|
5894f5e290 | ||
|
c381b885db | ||
|
756a522533 | ||
|
45cee3db2e | ||
|
59827af83c | ||
|
adb1a2ce99 | ||
|
4d086346af | ||
|
056fb0fea7 | ||
|
d7e6989d58 | ||
|
0fb307eb41 | ||
|
a7b7e1e49d | ||
|
e995cb4b7b | ||
|
808b0020d4 | ||
|
d5e1f75798 | ||
|
a1e01b2fad | ||
|
164a3e861e | ||
|
426f06d922 | ||
|
245b7a9d2f | ||
|
4c8eee72bd | ||
|
0a1df91f97 |
6
.github/workflows/e2e.yml
vendored
6
.github/workflows/e2e.yml
vendored
@@ -100,6 +100,12 @@ jobs:
|
||||
# Shared ENV Vars created in previous steps
|
||||
REMOTE_USER: ${{ env.TEST_USER2 }}
|
||||
TARGET: /var/www/html/${{ env.TEST_USER2 }}
|
||||
|
||||
- name: e2e Test ssh-deploy action - Default values
|
||||
uses: easingthemes/ssh-deploy@main
|
||||
env:
|
||||
# Shared ENV Vars created in previous steps
|
||||
REMOTE_USER: ${{ env.TEST_USER }}
|
||||
e2e-v3:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
|
9
.github/workflows/manual-release.yml
vendored
9
.github/workflows/manual-release.yml
vendored
@@ -6,11 +6,10 @@ on:
|
||||
description: 'Version'
|
||||
type: choice
|
||||
required: true
|
||||
default: patch
|
||||
default: fix
|
||||
options:
|
||||
- patch
|
||||
- minor
|
||||
- major
|
||||
- fix
|
||||
- feat
|
||||
dryRun:
|
||||
description: 'DryRun'
|
||||
type: boolean
|
||||
@@ -64,7 +63,7 @@ jobs:
|
||||
run: npm run build --if-present
|
||||
- name: Run Tests
|
||||
run: npm test --if-present
|
||||
- name: Publish npm package
|
||||
- name: Create a release - ${{ github.event.inputs.version }}
|
||||
uses: cycjimmy/semantic-release-action@v3
|
||||
with:
|
||||
dry_run: ${{ github.event.inputs.dryRun == 'true' }}
|
||||
|
12
README.md
12
README.md
@@ -83,7 +83,7 @@ or use the latest version from a branch, eg: ssh-deploy@main
|
||||
```
|
||||
- name: Deploy to Staging server
|
||||
uses: easingthemes/ssh-deploy@main
|
||||
env:
|
||||
with:
|
||||
SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }}
|
||||
ARGS: "-rlgoDzvc -i"
|
||||
SOURCE: "dist/"
|
||||
@@ -113,18 +113,18 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v1
|
||||
- uses: actions/checkout@v3
|
||||
- name: Install Node.js
|
||||
uses: actions/setup-node@v1
|
||||
uses: actions/setup-node@v3
|
||||
with:
|
||||
node-version: '10.x'
|
||||
node-version: '16.x'
|
||||
- name: Install npm dependencies
|
||||
run: npm install
|
||||
- name: Run build task
|
||||
run: npm run build --if-present
|
||||
- name: Deploy to Server
|
||||
uses: easingthemes/ssh-deploy@main
|
||||
env:
|
||||
with:
|
||||
SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }}
|
||||
ARGS: "-rlgoDzvc -i --delete"
|
||||
SOURCE: "dist/"
|
||||
@@ -149,6 +149,8 @@ I've added e2e test for this action.
|
||||
Real example is executed on every PR merge to `main`.
|
||||
Check actions tab for example.
|
||||
|
||||
When opening an issue, please add example of your step with env vars. You can add dummy values.
|
||||
|
||||
More info for SSH keys: https://www.ssh.com/ssh/public-key-authentication
|
||||
|
||||
## Tips
|
||||
|
@@ -22,7 +22,7 @@ inputs:
|
||||
TARGET:
|
||||
description: "Target directory"
|
||||
required: false
|
||||
default: "/home/REMOTE_USER/"
|
||||
default: ""
|
||||
ARGS:
|
||||
description: "Arguments to pass to rsync"
|
||||
required: false
|
||||
|
2
dist/index.js
vendored
2
dist/index.js
vendored
File diff suppressed because one or more lines are too long
@@ -1,3 +1,73 @@
|
||||
## [4.1.8](https://github.com/easingthemes/ssh-deploy/compare/v4.1.7...v4.1.8) (2023-02-21)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* rebuild and update readme ([98025d6](https://github.com/easingthemes/ssh-deploy/commit/98025d680e96a5c6c805e377a1b81de2f626aa1e))
|
||||
|
||||
## [4.1.7](https://github.com/easingthemes/ssh-deploy/compare/v4.1.6...v4.1.7) (2023-02-21)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* [#120](https://github.com/easingthemes/ssh-deploy/issues/120) check undefined data ([2fbb060](https://github.com/easingthemes/ssh-deploy/commit/2fbb06015d1a6ffd32e0100aaf1a1a46949e990e))
|
||||
|
||||
## [4.1.6](https://github.com/easingthemes/ssh-deploy/compare/v4.1.5...v4.1.6) (2023-02-21)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* [#118](https://github.com/easingthemes/ssh-deploy/issues/118) check undefined default values rebuild ([54f8b6c](https://github.com/easingthemes/ssh-deploy/commit/54f8b6c60b8f2f926d5ed9538557e5521a905d87))
|
||||
|
||||
## [4.1.5](https://github.com/easingthemes/ssh-deploy/compare/v4.1.4...v4.1.5) (2023-02-21)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* [#118](https://github.com/easingthemes/ssh-deploy/issues/118) check undefined default values ([f0c02fb](https://github.com/easingthemes/ssh-deploy/commit/f0c02fb2a5b3b69bb91004dd49d409eb6adfe7cd))
|
||||
|
||||
## [4.1.4](https://github.com/easingthemes/ssh-deploy/compare/v4.1.3...v4.1.4) (2023-02-21)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* [#113](https://github.com/easingthemes/ssh-deploy/issues/113) limit ssh script input ([5894f5e](https://github.com/easingthemes/ssh-deploy/commit/5894f5e29008feccaf42787330ec8f49f3ad50b0))
|
||||
|
||||
## [4.1.3](https://github.com/easingthemes/ssh-deploy/compare/v4.1.2...v4.1.3) (2023-02-21)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* [#113](https://github.com/easingthemes/ssh-deploy/issues/113) limit ssh script output - rebuild ([756a522](https://github.com/easingthemes/ssh-deploy/commit/756a522533d2206203b5d13b5aa11c88b3313784))
|
||||
|
||||
## [4.1.2](https://github.com/easingthemes/ssh-deploy/compare/v4.1.1...v4.1.2) (2023-02-21)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* [#113](https://github.com/easingthemes/ssh-deploy/issues/113) limit ssh script output ([59827af](https://github.com/easingthemes/ssh-deploy/commit/59827af83c934996efda72f9fbd1fcd0bb9ccaac))
|
||||
|
||||
## [4.1.1](https://github.com/easingthemes/ssh-deploy/compare/v4.1.0...v4.1.1) (2023-02-21)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* fix default TARGET ([4d08634](https://github.com/easingthemes/ssh-deploy/commit/4d086346af62ac5d57fa37ee6bb46f8de8ad48c3))
|
||||
|
||||
# [4.1.0](https://github.com/easingthemes/ssh-deploy/compare/v4.0.5...v4.1.0) (2023-02-19)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* add ssh port from VARs, fix package-lock ([808b002](https://github.com/easingthemes/ssh-deploy/commit/808b0020d44b7c25ef1c13b3979ffdab4f503236))
|
||||
|
||||
## [4.0.5](https://github.com/easingthemes/ssh-deploy/compare/v4.0.4...v4.0.5) (2023-01-06)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* fix manual release action ([245b7a9](https://github.com/easingthemes/ssh-deploy/commit/245b7a9d2fe5272ee34608f86a612d643694c23b))
|
||||
|
||||
## [4.0.4](https://github.com/easingthemes/ssh-deploy/compare/v4.0.3...v4.0.4) (2023-01-03)
|
||||
|
||||
|
||||
|
15
package-lock.json
generated
15
package-lock.json
generated
@@ -1,14 +1,15 @@
|
||||
{
|
||||
"name": "@draganfilipovic/ssh-deploy",
|
||||
"version": "4.0.3",
|
||||
"version": "4.1.8",
|
||||
"lockfileVersion": 2,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "@draganfilipovic/ssh-deploy",
|
||||
"version": "4.0.3",
|
||||
"version": "4.1.8",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"os": "^0.1.2",
|
||||
"rsyncwrapper": "^3.0.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
@@ -1483,6 +1484,11 @@
|
||||
"node": ">= 0.8.0"
|
||||
}
|
||||
},
|
||||
"node_modules/os": {
|
||||
"version": "0.1.2",
|
||||
"resolved": "https://registry.npmjs.org/os/-/os-0.1.2.tgz",
|
||||
"integrity": "sha512-ZoXJkvAnljwvc56MbvhtKVWmSkzV712k42Is2mA0+0KTSRakq5XXuXpjZjgAt9ctzl51ojhQWakQQpmOvXWfjQ=="
|
||||
},
|
||||
"node_modules/p-limit": {
|
||||
"version": "3.1.0",
|
||||
"resolved": "https://registry.npmjs.org/p-limit/-/p-limit-3.1.0.tgz",
|
||||
@@ -3061,6 +3067,11 @@
|
||||
"word-wrap": "^1.2.3"
|
||||
}
|
||||
},
|
||||
"os": {
|
||||
"version": "0.1.2",
|
||||
"resolved": "https://registry.npmjs.org/os/-/os-0.1.2.tgz",
|
||||
"integrity": "sha512-ZoXJkvAnljwvc56MbvhtKVWmSkzV712k42Is2mA0+0KTSRakq5XXuXpjZjgAt9ctzl51ojhQWakQQpmOvXWfjQ=="
|
||||
},
|
||||
"p-limit": {
|
||||
"version": "3.1.0",
|
||||
"resolved": "https://registry.npmjs.org/p-limit/-/p-limit-3.1.0.tgz",
|
||||
|
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@draganfilipovic/ssh-deploy",
|
||||
"version": "4.0.4",
|
||||
"version": "4.1.8",
|
||||
"description": "Fast NodeJS action to deploy specific directory from `GITHUB_WORKSPACE` to a server via rsync over ssh.",
|
||||
"main": "dist/index.js",
|
||||
"files": [
|
||||
@@ -30,6 +30,7 @@
|
||||
},
|
||||
"homepage": "https://github.com/easingthemes/ssh-deploy#readme",
|
||||
"dependencies": {
|
||||
"os": "^0.1.2",
|
||||
"rsyncwrapper": "^3.0.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
|
@@ -20,7 +20,7 @@ const run = async () => {
|
||||
const { path: privateKeyPath } = getPrivateKeyPath(deployKeyName);
|
||||
// Update known hosts if ssh command is present to avoid prompt
|
||||
if (scriptBefore || scriptAfter) {
|
||||
updateKnownHosts(remoteHost);
|
||||
updateKnownHosts(remoteHost, remotePort);
|
||||
}
|
||||
// Check Script before
|
||||
if (scriptBefore) {
|
||||
|
@@ -7,7 +7,7 @@ const inputNames = [
|
||||
'SCRIPT_BEFORE', 'SCRIPT_AFTER'];
|
||||
|
||||
const githubWorkspace = process.env.GITHUB_WORKSPACE;
|
||||
const remoteUser = process.env.REMOTE_USER;
|
||||
const remoteUser = process.env.REMOTE_USER || process.env.INPUT_REMOTE_USER;
|
||||
|
||||
const defaultInputs = {
|
||||
source: '',
|
||||
@@ -24,7 +24,7 @@ const inputs = {
|
||||
|
||||
inputNames.forEach((input) => {
|
||||
const inputName = snakeToCamel(input.toLowerCase());
|
||||
const inputVal = process.env[input] || process.env[`INPUT_${input}`];
|
||||
const inputVal = process.env[input] || process.env[`INPUT_${input}`] || defaultInputs[inputName];
|
||||
const validVal = inputVal === undefined ? defaultInputs[inputName] : inputVal;
|
||||
let extendedVal = validVal;
|
||||
// eslint-disable-next-line default-case
|
||||
|
@@ -1,5 +1,5 @@
|
||||
const { exec } = require('child_process');
|
||||
const { sshServer, githubWorkspace } = require('./inputs');
|
||||
const { sshServer, githubWorkspace, remotePort } = require('./inputs');
|
||||
const { writeToFile } = require('./helpers');
|
||||
|
||||
const handleError = (message, isRequired, callback) => {
|
||||
@@ -15,17 +15,20 @@ const remoteCmd = async (content, privateKeyPath, isRequired, label) => new Prom
|
||||
const filename = `local_ssh_script-${label}.sh`;
|
||||
try {
|
||||
writeToFile({ dir: githubWorkspace, filename, content });
|
||||
const dataLimit = 10000;
|
||||
const rsyncStdout = (process.env.RSYNC_STDOUT || '').substring(0, dataLimit);
|
||||
console.log(`Executing remote script: ssh -i ${privateKeyPath} ${sshServer}`);
|
||||
exec(
|
||||
`DEBIAN_FRONTEND=noninteractive ssh -i ${privateKeyPath} -o StrictHostKeyChecking=no ${sshServer} 'RSYNC_STDOUT="${process.env.RSYNC_STDOUT}" bash -s' < ${filename}`,
|
||||
(err, data, stderr) => {
|
||||
`DEBIAN_FRONTEND=noninteractive ssh -p ${(remotePort || 22)} -i ${privateKeyPath} -o StrictHostKeyChecking=no ${sshServer} 'RSYNC_STDOUT="${rsyncStdout}" bash -s' < ${filename}`,
|
||||
(err, data = '', stderr = '') => {
|
||||
if (err) {
|
||||
const message = `⚠️ [CMD] Remote script failed: ${err.message}`;
|
||||
console.warn(`${message} \n`, data, stderr);
|
||||
handleError(message, isRequired, reject);
|
||||
} else {
|
||||
console.log('✅ [CMD] Remote script executed. \n', data, stderr);
|
||||
resolve(data);
|
||||
const limited = data.substring(0, dataLimit);
|
||||
console.log('✅ [CMD] Remote script executed. \n', limited, stderr);
|
||||
resolve(limited);
|
||||
}
|
||||
}
|
||||
);
|
||||
|
@@ -1,6 +1,7 @@
|
||||
const { join } = require('path');
|
||||
const { execSync } = require('child_process');
|
||||
const { writeToFile } = require('./helpers');
|
||||
const { EOL } = require('os');
|
||||
|
||||
const KNOWN_HOSTS = 'known_hosts';
|
||||
const getPrivateKeyPath = (filename = '') => {
|
||||
@@ -19,15 +20,15 @@ const addSshKey = (content, deployKeyName) => {
|
||||
const { dir, filename } = getPrivateKeyPath(deployKeyName);
|
||||
writeToFile({ dir, filename: KNOWN_HOSTS, content: '' });
|
||||
console.log('✅ [SSH] known_hosts file ensured', dir);
|
||||
writeToFile({ dir, filename, content, isRequired: true, mode: '0400' });
|
||||
writeToFile({ dir, filename, content: `${content}${EOL}`, isRequired: true, mode: '0400' });
|
||||
console.log('✅ [SSH] key added to `.ssh` dir ', dir, filename);
|
||||
};
|
||||
|
||||
const updateKnownHosts = (host) => {
|
||||
const updateKnownHosts = (host, remotePort) => {
|
||||
const { knownHostsPath } = getPrivateKeyPath();
|
||||
console.log('[SSH] Adding host to `known_hosts` ....', host, knownHostsPath);
|
||||
try {
|
||||
execSync(`ssh-keyscan -H ${host} >> ${knownHostsPath}`, {
|
||||
execSync(`ssh-keyscan -p ${(remotePort || 22)} -H ${host} >> ${knownHostsPath}`, {
|
||||
stdio: 'inherit'
|
||||
});
|
||||
} catch (error) {
|
||||
|
Reference in New Issue
Block a user