mirror of
https://github.com/easingthemes/ssh-deploy.git
synced 2024-11-19 08:08:05 +08:00
Compare commits
2 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
fed234c433 | ||
|
60a3a662e8 |
6
.github/workflows/e2e.yml
vendored
6
.github/workflows/e2e.yml
vendored
@@ -100,12 +100,6 @@ 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,10 +6,11 @@ on:
|
||||
description: 'Version'
|
||||
type: choice
|
||||
required: true
|
||||
default: fix
|
||||
default: patch
|
||||
options:
|
||||
- fix
|
||||
- feat
|
||||
- patch
|
||||
- minor
|
||||
- major
|
||||
dryRun:
|
||||
description: 'DryRun'
|
||||
type: boolean
|
||||
@@ -63,7 +64,7 @@ jobs:
|
||||
run: npm run build --if-present
|
||||
- name: Run Tests
|
||||
run: npm test --if-present
|
||||
- name: Create a release - ${{ github.event.inputs.version }}
|
||||
- name: Publish npm package
|
||||
uses: cycjimmy/semantic-release-action@v3
|
||||
with:
|
||||
dry_run: ${{ github.event.inputs.dryRun == 'true' }}
|
||||
|
@@ -22,7 +22,7 @@ inputs:
|
||||
TARGET:
|
||||
description: "Target directory"
|
||||
required: false
|
||||
default: ""
|
||||
default: "/home/REMOTE_USER/"
|
||||
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,52 +1,3 @@
|
||||
## [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)
|
||||
|
||||
|
||||
|
4
package-lock.json
generated
4
package-lock.json
generated
@@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "@draganfilipovic/ssh-deploy",
|
||||
"version": "4.0.5",
|
||||
"version": "4.0.3",
|
||||
"lockfileVersion": 2,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "@draganfilipovic/ssh-deploy",
|
||||
"version": "4.0.5",
|
||||
"version": "4.0.3",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"rsyncwrapper": "^3.0.1"
|
||||
|
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@draganfilipovic/ssh-deploy",
|
||||
"version": "4.1.5",
|
||||
"version": "4.0.4",
|
||||
"description": "Fast NodeJS action to deploy specific directory from `GITHUB_WORKSPACE` to a server via rsync over ssh.",
|
||||
"main": "dist/index.js",
|
||||
"files": [
|
||||
|
@@ -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, remotePort);
|
||||
updateKnownHosts(remoteHost);
|
||||
}
|
||||
// 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 || process.env.INPUT_REMOTE_USER;
|
||||
const remoteUser = process.env.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}`] || defaultInputs[inputName];
|
||||
const inputVal = process.env[input] || process.env[`INPUT_${input}`];
|
||||
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, remotePort } = require('./inputs');
|
||||
const { sshServer, githubWorkspace } = require('./inputs');
|
||||
const { writeToFile } = require('./helpers');
|
||||
|
||||
const handleError = (message, isRequired, callback) => {
|
||||
@@ -15,20 +15,17 @@ 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 -p ${(remotePort || 22)} -i ${privateKeyPath} -o StrictHostKeyChecking=no ${sshServer} 'RSYNC_STDOUT="${rsyncStdout}" bash -s' < ${filename}`,
|
||||
`DEBIAN_FRONTEND=noninteractive ssh -i ${privateKeyPath} -o StrictHostKeyChecking=no ${sshServer} 'RSYNC_STDOUT="${process.env.RSYNC_STDOUT}" 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 {
|
||||
const limited = data.substring(0, dataLimit);
|
||||
console.log('✅ [CMD] Remote script executed. \n', limited, stderr);
|
||||
resolve(limited);
|
||||
console.log('✅ [CMD] Remote script executed. \n', data, stderr);
|
||||
resolve(data);
|
||||
}
|
||||
}
|
||||
);
|
||||
|
@@ -19,15 +19,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: `${content}\r\n`, isRequired: true, mode: '0400' });
|
||||
writeToFile({ dir, filename, content, isRequired: true, mode: '0400' });
|
||||
console.log('✅ [SSH] key added to `.ssh` dir ', dir, filename);
|
||||
};
|
||||
|
||||
const updateKnownHosts = (host, remotePort) => {
|
||||
const updateKnownHosts = (host) => {
|
||||
const { knownHostsPath } = getPrivateKeyPath();
|
||||
console.log('[SSH] Adding host to `known_hosts` ....', host, knownHostsPath);
|
||||
try {
|
||||
execSync(`ssh-keyscan -p ${(remotePort || 22)} -H ${host} >> ${knownHostsPath}`, {
|
||||
execSync(`ssh-keyscan -H ${host} >> ${knownHostsPath}`, {
|
||||
stdio: 'inherit'
|
||||
});
|
||||
} catch (error) {
|
||||
|
Reference in New Issue
Block a user