mirror of
https://github.com/easingthemes/ssh-deploy.git
synced 2024-11-19 08:08:05 +08:00
Compare commits
68 Commits
v3
...
3f5d9aab1a
Author | SHA1 | Date | |
---|---|---|---|
|
3f5d9aab1a | ||
|
2942523001 | ||
|
ef20db4468 | ||
|
627ac29ece | ||
|
66f6e4b367 | ||
|
d91ea7e0f7 | ||
|
28d946e487 | ||
|
3ab5951ec1 | ||
|
cf583aab4f | ||
|
8ba86462c0 | ||
|
e7f0312c8c | ||
|
35ccd2ccc4 | ||
|
ed53b09c84 | ||
|
f9797b28d5 | ||
|
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 | ||
|
845b7f6f1f | ||
|
2a32c8dcde | ||
|
0b63b85565 | ||
|
450bf423f3 | ||
|
affc58a8b7 | ||
|
8c12d45929 | ||
|
85987f4567 | ||
|
3ef66d0be9 | ||
|
79363f2b74 | ||
|
7c21074882 | ||
|
9f191f4263 | ||
|
006cf3021d | ||
|
8be4106fce | ||
|
7c9b40539e | ||
|
2169399fef | ||
|
2be7efb376 | ||
|
e6e41a57ec | ||
|
c8d57ec8b4 |
2
.github/workflows/e2e-manual.yml
vendored
2
.github/workflows/e2e-manual.yml
vendored
@@ -6,7 +6,7 @@ on:
|
||||
ARGS:
|
||||
description: 'ARGS'
|
||||
required: true
|
||||
default: '-rltgoDzvO --delete --chmod=ugo+rwX --progress'
|
||||
default: '-rlgoDzvc -i --delete --chmod=ugo+rwX --progress'
|
||||
EXCLUDE:
|
||||
description: 'EXCLUDE'
|
||||
required: true
|
||||
|
81
.github/workflows/e2e.yml
vendored
81
.github/workflows/e2e.yml
vendored
@@ -74,7 +74,7 @@ jobs:
|
||||
|
||||
- name: set shared ENV variables for multi target deployment
|
||||
run: |
|
||||
echo "ARGS=-rltgoDzvOR --delete --chmod=ugo+rwX --progress" >> $GITHUB_ENV
|
||||
echo "ARGS=-rlgoDzvcR -i --delete --chmod=ugo+rwX --progress" >> $GITHUB_ENV
|
||||
echo "SSH_CMD_ARGS=-o StrictHostKeyChecking=no, -o UserKnownHostsFile=/dev/null" >> $GITHUB_ENV
|
||||
echo "SOURCE=test_project/ test_project2/" >> $GITHUB_ENV
|
||||
echo "EXCLUDE=skip_dir/, /node_modules/" >> $GITHUB_ENV
|
||||
@@ -95,8 +95,85 @@ jobs:
|
||||
TARGET: /var/www/html/${{ env.TEST_USER }}
|
||||
|
||||
- name: e2e Test ssh-deploy action - Target 2
|
||||
uses: easingthemes/ssh-deploy@feature/main
|
||||
uses: easingthemes/ssh-deploy@main
|
||||
env:
|
||||
# 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
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
|
||||
# : ---------------------------------------------------------------
|
||||
# : START E2E Test Specific - steps
|
||||
# : ----------------------------------------------------------------
|
||||
|
||||
- name: E2E Test Specific - Clean up old test files
|
||||
run: |
|
||||
docker stop ssh-host-container || true && docker rm ssh-host-container || true
|
||||
|
||||
- name: E2E Test Specific - Create ssh keys
|
||||
run: |
|
||||
echo $HOME
|
||||
ls -la $HOME
|
||||
ssh-keygen -m PEM -t rsa -b 4096 -f "$HOME/.ssh/id_rsa" -N ""
|
||||
eval `ssh-agent -s`
|
||||
ssh-add "$HOME/.ssh/id_rsa"
|
||||
ssh-add -l
|
||||
echo "SSH_PRIVATE_KEY<<EOF" >> $GITHUB_ENV
|
||||
cat $HOME/.ssh/id_rsa >> $GITHUB_ENV
|
||||
echo "EOF" >> $GITHUB_ENV
|
||||
|
||||
- name: E2E Test Specific - Build Host Server Image
|
||||
working-directory: ${{ env.TEST_HOST_DOCKER }}
|
||||
run: |
|
||||
docker build \
|
||||
-t ssh-host-image . \
|
||||
--build-arg SSH_PUB_KEY="$(cat $HOME/.ssh/id_rsa.pub)"
|
||||
docker run -d -p 8822:22 --name=ssh-host-container ssh-host-image
|
||||
docker exec ssh-host-container sh -c "hostname --ip-address" > ip.txt
|
||||
echo "REMOTE_HOST<<EOF" >> $GITHUB_ENV
|
||||
cat ip.txt >> $GITHUB_ENV
|
||||
echo "EOF" >> $GITHUB_ENV
|
||||
shell: bash
|
||||
|
||||
- name: E2E Test Specific - Create project file
|
||||
run: |
|
||||
mkdir test_project2 && cd "$_"
|
||||
truncate -s 5MB info2.txt
|
||||
cd ../
|
||||
mkdir test_project && cd "$_"
|
||||
touch index.html
|
||||
date +"%Y-%m-%d %H:%M:%S,%3N" >> index.html
|
||||
truncate -s 50MB image.svg
|
||||
truncate -s 5MB info.txt
|
||||
truncate -s 500MB big_file.txt
|
||||
mkdir skip_dir && cd "$_"
|
||||
truncate -s 5MB text_in_skip_dir.txt
|
||||
cd ../
|
||||
cat index.html
|
||||
echo "test_project:" && ls -lR
|
||||
echo "skip_dir:" && ls -lR skip_dir
|
||||
|
||||
# ----------------------------------------------------------------
|
||||
# END E2E Test Specific - steps
|
||||
# ----------------------------------------------------------------
|
||||
|
||||
- name: e2e Test ssh-deploy action - Target 1
|
||||
uses: easingthemes/ssh-deploy@v3
|
||||
env:
|
||||
# Shared ENV Vars created in previous steps
|
||||
REMOTE_USER: ${{ env.TEST_USER }}
|
||||
TARGET: /var/www/html/${{ env.TEST_USER }}
|
||||
SOURCE: test_project/
|
||||
EXCLUDE: skip_dir/, /node_modules/
|
||||
ARGS: -rlgoDzvcO
|
||||
|
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' }}
|
||||
|
25
README.md
25
README.md
@@ -28,6 +28,8 @@ The keys should be generated using the PEM format. You can use this command
|
||||
```
|
||||
ssh-keygen -m PEM -t rsa -b 4096
|
||||
```
|
||||
**Please Note:** You should not set a Passphrase (keep it empty) for the private key you generated.
|
||||
Because rsync ssh (used for deploy) does not support private key password to be entered as a command line parameter.
|
||||
|
||||
##### 2. `REMOTE_HOST` [required]
|
||||
|
||||
@@ -41,7 +43,7 @@ eg: myusername
|
||||
|
||||
eg: '59184'
|
||||
|
||||
##### 5. `ARGS` (optional, default '-rltgoDzvO')
|
||||
##### 5. `ARGS` (optional, default '-rlgoDzvc -i')
|
||||
|
||||
For any initial/required rsync flags, eg: `-avzr --delete`
|
||||
|
||||
@@ -62,6 +64,8 @@ path to exclude separated by `,`, ie: `/dist/, /node_modules/`
|
||||
|
||||
Script to run on host machine before rsync. Single line or multiline commands.
|
||||
Execution is preformed by storing commands in `.sh` file and executing it via `.bash` over `ssh`
|
||||
If you have issues with `ssh` connection, use this var, eg `SCRIPT_BEFORE: ls`.
|
||||
This will force `known_hosts` update, adding your host via `ssh-keyscan`.
|
||||
|
||||
##### 10. `SCRIPT_AFTER` (optional, default '')
|
||||
|
||||
@@ -81,9 +85,9 @@ 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: "-rltgoDzvO"
|
||||
ARGS: "-rlgoDzvc -i"
|
||||
SOURCE: "dist/"
|
||||
REMOTE_HOST: ${{ secrets.REMOTE_HOST }}
|
||||
REMOTE_USER: ${{ secrets.REMOTE_USER }}
|
||||
@@ -111,20 +115,20 @@ 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: "-rltgoDzvO --delete"
|
||||
ARGS: "-rlgoDzvc -i --delete"
|
||||
SOURCE: "dist/"
|
||||
REMOTE_HOST: ${{ secrets.REMOTE_HOST }}
|
||||
REMOTE_USER: ${{ secrets.REMOTE_USER }}
|
||||
@@ -140,13 +144,15 @@ Almost 95% of the issues are related to wrong SSH connection or `rsync` params a
|
||||
These issues are not related to the action itself.
|
||||
|
||||
- Check manually your ssh connection from your client before opening a bug report.
|
||||
- Check `rsync` params for your use-case. Default params are not going to be enough wor everyone, it highly depends on your setup.
|
||||
- Check `rsync` params for your use-case. Default params are not necessarily going to be enough for everyone, it highly depends on your setup.
|
||||
- Check manually your rsync command from your client before opening a bug report.
|
||||
|
||||
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
|
||||
@@ -156,6 +162,7 @@ For complex use cases, use `ARGS` and `SSH_CMD_ARGS` to fully configure `rsync`
|
||||
- If you need to use multiple steps, eg multi targets deployment, save shared ENV variables in `>> $GITHUB_ENV`.
|
||||
Check .github/workflows/e2e.yml for an example
|
||||
- For multi sources, use -R ARG to manipulate folders structure.
|
||||
- Great post about `rsync` options specific to usage of this action: https://logansnotes.com/2020/gh-action-site-deploy/
|
||||
|
||||
|
||||
## Disclaimer
|
||||
|
@@ -22,11 +22,11 @@ inputs:
|
||||
TARGET:
|
||||
description: "Target directory"
|
||||
required: false
|
||||
default: "/home/REMOTE_USER/"
|
||||
default: ""
|
||||
ARGS:
|
||||
description: "Arguments to pass to rsync"
|
||||
required: false
|
||||
default: "-rltgoDzvO"
|
||||
default: "-rlgoDzvc -i"
|
||||
SSH_CMD_ARGS:
|
||||
description: "An array of ssh arguments, they must be prefixed with -o and separated by a comma, for example: -o SomeArgument=no, -o SomeOtherArgument=5 "
|
||||
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,127 @@
|
||||
## [4.1.9](https://github.com/easingthemes/ssh-deploy/compare/v4.1.8...v4.1.9) (2023-09-24)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* add compiled file ([627ac29](https://github.com/easingthemes/ssh-deploy/commit/627ac29ece9dc2f1185a50d1002bc2c968fc973c))
|
||||
* add uuid for ssh scripts ([66f6e4b](https://github.com/easingthemes/ssh-deploy/commit/66f6e4b367ea39479c285234797a4e86c90d9abd))
|
||||
|
||||
## [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)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* update sub dependencies ([2a32c8d](https://github.com/easingthemes/ssh-deploy/commit/2a32c8dcde2d64394a3577decdd9c902f37a30f8))
|
||||
|
||||
## [4.0.3](https://github.com/easingthemes/ssh-deploy/compare/v4.0.2...v4.0.3) (2023-01-03)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* update v3 e2e test ([450bf42](https://github.com/easingthemes/ssh-deploy/commit/450bf423f388777bde052ad7b5bc24eca392434d))
|
||||
|
||||
## [4.0.2](https://github.com/easingthemes/ssh-deploy/compare/v4.0.1...v4.0.2) (2023-01-03)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* add githubWorkspace as default source root ([3ef66d0](https://github.com/easingthemes/ssh-deploy/commit/3ef66d0be999ee45434505e8bedea4f8b5b5a909))
|
||||
|
||||
## [4.0.1](https://github.com/easingthemes/ssh-deploy/compare/v4.0.0...v4.0.1) (2023-01-03)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* fix default source if empty ([9f191f4](https://github.com/easingthemes/ssh-deploy/commit/9f191f42633c4a0f66054f0fc229c9e30a08f00c))
|
||||
|
||||
# [4.0.0](https://github.com/easingthemes/ssh-deploy/compare/v3.4.3...v4.0.0) (2023-01-03)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* rebuild ([2169399](https://github.com/easingthemes/ssh-deploy/commit/2169399fef9a60a2fea1ab03cce4ec8c2371e5c2))
|
||||
|
||||
|
||||
### Performance Improvements
|
||||
|
||||
* update default rsync options ([2be7efb](https://github.com/easingthemes/ssh-deploy/commit/2be7efb376866327c1d1209f51eb43f34f07b354))
|
||||
|
||||
|
||||
### BREAKING CHANGES
|
||||
|
||||
* Default rsync options updated to speed up default deployments.
|
||||
from `rltgoDzvO` to `-rlgoDzvc -i`
|
||||
|
||||
## [3.4.3](https://github.com/easingthemes/ssh-deploy/compare/v3.4.2...v3.4.3) (2023-01-03)
|
||||
|
||||
|
||||
|
97
package-lock.json
generated
97
package-lock.json
generated
@@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "@draganfilipovic/ssh-deploy",
|
||||
"version": "3.4.3",
|
||||
"version": "4.1.8",
|
||||
"lockfileVersion": 2,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "@draganfilipovic/ssh-deploy",
|
||||
"version": "3.4.3",
|
||||
"version": "4.1.8",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"rsyncwrapper": "^3.0.1"
|
||||
@@ -1357,6 +1357,18 @@
|
||||
"integrity": "sha512-0KpjqXRVvrYyCsX1swR/XTK0va6VQkQM6MNo7PqW77ByjAhoARA8EfrP1N4+KlKj8YS0ZUCtRT/YUuhyYDujIQ==",
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/lru-cache": {
|
||||
"version": "6.0.0",
|
||||
"resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz",
|
||||
"integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"yallist": "^4.0.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=10"
|
||||
}
|
||||
},
|
||||
"node_modules/minimatch": {
|
||||
"version": "3.1.2",
|
||||
"resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz",
|
||||
@@ -1483,6 +1495,16 @@
|
||||
"node": ">= 0.8.0"
|
||||
}
|
||||
},
|
||||
"node_modules/optionator/node_modules/word-wrap": {
|
||||
"name": "@aashutoshrathi/word-wrap",
|
||||
"version": "1.2.5",
|
||||
"resolved": "https://registry.npmjs.org/@aashutoshrathi/word-wrap/-/word-wrap-1.2.5.tgz",
|
||||
"integrity": "sha512-plhoNEfSVdHMKXQyAxvH0Zyv3/4NL8r6pwgMQdmHR2vBUXn2t74PN2pBRppqKUa6RMT0yldyvOHG5Dbjwy2mBQ==",
|
||||
"dev": true,
|
||||
"engines": {
|
||||
"node": ">=0.10.0"
|
||||
}
|
||||
},
|
||||
"node_modules/p-limit": {
|
||||
"version": "3.1.0",
|
||||
"resolved": "https://registry.npmjs.org/p-limit/-/p-limit-3.1.0.tgz",
|
||||
@@ -1722,12 +1744,18 @@
|
||||
}
|
||||
},
|
||||
"node_modules/semver": {
|
||||
"version": "6.3.0",
|
||||
"resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz",
|
||||
"integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==",
|
||||
"version": "7.5.4",
|
||||
"resolved": "https://registry.npmjs.org/semver/-/semver-7.5.4.tgz",
|
||||
"integrity": "sha512-1bCSESV6Pv+i21Hvpxp3Dx+pSD8lIPt8uVjRrxAUt/nbswYc+tK6Y2btiULjd4+fnq15PX+nqQDC7Oft7WkwcA==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"lru-cache": "^6.0.0"
|
||||
},
|
||||
"bin": {
|
||||
"semver": "bin/semver.js"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=10"
|
||||
}
|
||||
},
|
||||
"node_modules/shebang-command": {
|
||||
@@ -1947,21 +1975,18 @@
|
||||
"url": "https://github.com/sponsors/ljharb"
|
||||
}
|
||||
},
|
||||
"node_modules/word-wrap": {
|
||||
"version": "1.2.3",
|
||||
"resolved": "https://registry.npmjs.org/word-wrap/-/word-wrap-1.2.3.tgz",
|
||||
"integrity": "sha512-Hz/mrNwitNRh/HUAtM/VT/5VH+ygD6DV7mYKZAtHOrbs8U7lvPS6xf7EJKMF0uW1KJCl0H701g3ZGus+muE5vQ==",
|
||||
"dev": true,
|
||||
"engines": {
|
||||
"node": ">=0.10.0"
|
||||
}
|
||||
},
|
||||
"node_modules/wrappy": {
|
||||
"version": "1.0.2",
|
||||
"resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz",
|
||||
"integrity": "sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==",
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/yallist": {
|
||||
"version": "4.0.0",
|
||||
"resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz",
|
||||
"integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==",
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/yocto-queue": {
|
||||
"version": "0.1.0",
|
||||
"resolved": "https://registry.npmjs.org/yocto-queue/-/yocto-queue-0.1.0.tgz",
|
||||
@@ -2354,7 +2379,7 @@
|
||||
"confusing-browser-globals": "^1.0.10",
|
||||
"object.assign": "^4.1.2",
|
||||
"object.entries": "^1.1.5",
|
||||
"semver": "^6.3.0"
|
||||
"semver": "^7.5.2"
|
||||
}
|
||||
},
|
||||
"eslint-import-resolver-node": {
|
||||
@@ -2965,6 +2990,15 @@
|
||||
"integrity": "sha512-0KpjqXRVvrYyCsX1swR/XTK0va6VQkQM6MNo7PqW77ByjAhoARA8EfrP1N4+KlKj8YS0ZUCtRT/YUuhyYDujIQ==",
|
||||
"dev": true
|
||||
},
|
||||
"lru-cache": {
|
||||
"version": "6.0.0",
|
||||
"resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz",
|
||||
"integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"yallist": "^4.0.0"
|
||||
}
|
||||
},
|
||||
"minimatch": {
|
||||
"version": "3.1.2",
|
||||
"resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz",
|
||||
@@ -3058,7 +3092,15 @@
|
||||
"levn": "^0.4.1",
|
||||
"prelude-ls": "^1.2.1",
|
||||
"type-check": "^0.4.0",
|
||||
"word-wrap": "^1.2.3"
|
||||
"word-wrap": "npm:@aashutoshrathi/word-wrap@1.2.5"
|
||||
},
|
||||
"dependencies": {
|
||||
"word-wrap": {
|
||||
"version": "npm:@aashutoshrathi/word-wrap@1.2.5",
|
||||
"resolved": "https://registry.npmjs.org/@aashutoshrathi/word-wrap/-/word-wrap-1.2.5.tgz",
|
||||
"integrity": "sha512-plhoNEfSVdHMKXQyAxvH0Zyv3/4NL8r6pwgMQdmHR2vBUXn2t74PN2pBRppqKUa6RMT0yldyvOHG5Dbjwy2mBQ==",
|
||||
"dev": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"p-limit": {
|
||||
@@ -3205,10 +3247,13 @@
|
||||
}
|
||||
},
|
||||
"semver": {
|
||||
"version": "6.3.0",
|
||||
"resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz",
|
||||
"integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==",
|
||||
"dev": true
|
||||
"version": "7.5.4",
|
||||
"resolved": "https://registry.npmjs.org/semver/-/semver-7.5.4.tgz",
|
||||
"integrity": "sha512-1bCSESV6Pv+i21Hvpxp3Dx+pSD8lIPt8uVjRrxAUt/nbswYc+tK6Y2btiULjd4+fnq15PX+nqQDC7Oft7WkwcA==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"lru-cache": "^6.0.0"
|
||||
}
|
||||
},
|
||||
"shebang-command": {
|
||||
"version": "2.0.0",
|
||||
@@ -3370,18 +3415,18 @@
|
||||
"is-symbol": "^1.0.3"
|
||||
}
|
||||
},
|
||||
"word-wrap": {
|
||||
"version": "1.2.3",
|
||||
"resolved": "https://registry.npmjs.org/word-wrap/-/word-wrap-1.2.3.tgz",
|
||||
"integrity": "sha512-Hz/mrNwitNRh/HUAtM/VT/5VH+ygD6DV7mYKZAtHOrbs8U7lvPS6xf7EJKMF0uW1KJCl0H701g3ZGus+muE5vQ==",
|
||||
"dev": true
|
||||
},
|
||||
"wrappy": {
|
||||
"version": "1.0.2",
|
||||
"resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz",
|
||||
"integrity": "sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==",
|
||||
"dev": true
|
||||
},
|
||||
"yallist": {
|
||||
"version": "4.0.0",
|
||||
"resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz",
|
||||
"integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==",
|
||||
"dev": true
|
||||
},
|
||||
"yocto-queue": {
|
||||
"version": "0.1.0",
|
||||
"resolved": "https://registry.npmjs.org/yocto-queue/-/yocto-queue-0.1.0.tgz",
|
||||
|
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@draganfilipovic/ssh-deploy",
|
||||
"version": "3.4.3",
|
||||
"version": "4.1.9",
|
||||
"description": "Fast NodeJS action to deploy specific directory from `GITHUB_WORKSPACE` to a server via rsync over ssh.",
|
||||
"main": "dist/index.js",
|
||||
"files": [
|
||||
@@ -37,5 +37,9 @@
|
||||
"eslint": "^8.30.0",
|
||||
"eslint-config-airbnb-base": "^15.0.0",
|
||||
"eslint-plugin-import": "^2.26.0"
|
||||
},
|
||||
"overrides": {
|
||||
"word-wrap": "npm:@aashutoshrathi/word-wrap@1.2.5",
|
||||
"semver": "^7.5.2"
|
||||
}
|
||||
}
|
||||
|
@@ -10,7 +10,8 @@ const run = async () => {
|
||||
source, remoteUser, remoteHost, remotePort,
|
||||
deployKeyName, sshPrivateKey,
|
||||
args, exclude, sshCmdArgs,
|
||||
scriptBefore, scriptAfter,
|
||||
scriptBefore, scriptBeforeRequired,
|
||||
scriptAfter, scriptAfterRequired,
|
||||
rsyncServer
|
||||
} = inputs;
|
||||
// Validate required inputs
|
||||
@@ -20,11 +21,11 @@ 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) {
|
||||
await remoteCmdBefore(scriptBefore, privateKeyPath);
|
||||
await remoteCmdBefore(scriptBefore, privateKeyPath, scriptBeforeRequired);
|
||||
}
|
||||
/* eslint-disable object-property-newline */
|
||||
await sshDeploy({
|
||||
@@ -33,7 +34,7 @@ const run = async () => {
|
||||
});
|
||||
// Check script after
|
||||
if (scriptAfter) {
|
||||
await remoteCmdAfter(scriptAfter, privateKeyPath);
|
||||
await remoteCmdAfter(scriptAfter, privateKeyPath, scriptAfterRequired);
|
||||
}
|
||||
};
|
||||
|
||||
|
@@ -4,16 +4,16 @@ const inputNames = [
|
||||
'REMOTE_HOST', 'REMOTE_USER', 'REMOTE_PORT',
|
||||
'SSH_PRIVATE_KEY', 'DEPLOY_KEY_NAME',
|
||||
'SOURCE', 'TARGET', 'ARGS', 'SSH_CMD_ARGS', 'EXCLUDE',
|
||||
'SCRIPT_BEFORE', 'SCRIPT_AFTER'];
|
||||
'SCRIPT_BEFORE', 'SCRIPT_AFTER', 'SCRIPT_BEFORE_REQUIRED', 'SCRIPT_AFTER_REQUIRED'];
|
||||
|
||||
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: '',
|
||||
target: `/home/${remoteUser}/`,
|
||||
exclude: '',
|
||||
args: '-rltgoDzvO',
|
||||
args: '-rlgoDzvc -i',
|
||||
sshCmdArgs: '-o StrictHostKeyChecking=no',
|
||||
deployKeyName: `deploy_key_${remoteUser}_${Date.now()}`
|
||||
};
|
||||
@@ -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,6 @@
|
||||
const { exec } = require('child_process');
|
||||
const { sshServer, githubWorkspace } = require('./inputs');
|
||||
const crypto = require('crypto');
|
||||
const { sshServer, githubWorkspace, remotePort } = require('./inputs');
|
||||
const { writeToFile } = require('./helpers');
|
||||
|
||||
const handleError = (message, isRequired, callback) => {
|
||||
@@ -12,20 +13,24 @@ const handleError = (message, isRequired, callback) => {
|
||||
|
||||
// eslint-disable-next-line max-len
|
||||
const remoteCmd = async (content, privateKeyPath, isRequired, label) => new Promise((resolve, reject) => {
|
||||
const filename = `local_ssh_script-${label}.sh`;
|
||||
const uuid = crypto.randomUUID();
|
||||
const filename = `local_ssh_script-${label}-${uuid}.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,5 +1,6 @@
|
||||
const { join } = require('path');
|
||||
const { execSync } = require('child_process');
|
||||
const { EOL } = require('os');
|
||||
const { writeToFile } = require('./helpers');
|
||||
|
||||
const KNOWN_HOSTS = 'known_hosts';
|
||||
@@ -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