Feature/ssh cmd (#94)

* feat: Add SSH remote script support -  before and after rsync

* fix: remove __dirname

* feat: add sshCmdArgs option

* Add promise instead of callback

* fix: improve logs

* fix: Add simple command exists instead of a plugin

* add non interactive install

* feat: add onStderr and onStdout logs

* Improve reject messages

* feat: Add RSYNC_STDOUT env variable

* emoji updates

* fix: update workflow actions
This commit is contained in:
Dragan Filipović 2023-01-02 21:06:33 +01:00 committed by GitHub
parent a5d8edb941
commit ec9347f8c6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
17 changed files with 373 additions and 242 deletions

View file

@ -1,6 +1,8 @@
# ssh deployments
Deploy code with rsync over ssh, using NodeJS.
Deploy code with rsync over ssh.
Execute remote scripts before or after rsync
NodeJS version is more than a minute `faster` than simple Docker version.
@ -8,6 +10,8 @@ This GitHub Action deploys specific directory from `GITHUB_WORKSPACE` to a folde
This action would usually follow a build/test action which leaves deployable code in `GITHUB_WORKSPACE`, eg `dist`;
In addition to rsync, this action provides scripts execution on remote host before and/or after rsync.
# Configuration
Pass configuration with `env` vars
@ -53,6 +57,16 @@ The target directory
path to exclude separated by `,`, ie: `/dist/, /node_modules/`
##### 9. `SCRIPT_BEFORE` (optional, default '')
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`
##### 10. `SCRIPT_AFTER` (optional, default '')
Script to run on host machine after rsync.
Rsync output is stored in `$RSYNC_STDOUT` env variable.
# Usage
Use the latest version from Marketplace,eg: ssh-deploy@v2
@ -69,6 +83,13 @@ or use the latest version from a branch, eg: ssh-deploy@main
REMOTE_USER: ${{ secrets.REMOTE_USER }}
TARGET: ${{ secrets.REMOTE_TARGET }}
EXCLUDE: "/dist/, /node_modules/"
SCRIPT_BEFORE: |
whoami
ls -al
SCRIPT_AFTER: |
whoami
ls -al
echo $RSYNC_STDOUT
```
# Example usage in workflow
@ -107,13 +128,13 @@ jobs:
## Issues
This is a Github Action wrapping `rsync` via `ssh`. Only issues with action functionality can be fixed here.
This is a GitHub Action wrapping `rsync` via `ssh`. Only issues with action functionality can be fixed here.
Almost 95% of the issues are related to wrong SSH connection or `rsync` params and permissions.
This issues are not related to the action itself.
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 usecase. 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 going to be enough wor 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.