easingthemes / Ssh Deploy
Programming Languages
Projects that are alternatives of or similar to Ssh Deploy
ssh deployments
Deploy code with rsync over ssh, using NodeJS.
NodeJS version is more than a minute faster
than simple Docker version.
This GitHub Action deploys specific directory from GITHUB_WORKSPACE
to a folder on a server via rsync over ssh, using NodeJS.
This action would usually follow a build/test action which leaves deployable code in GITHUB_WORKSPACE
, eg dist
;
Configuration
Pass configuration with env
vars
SSH_PRIVATE_KEY
[required]
1. Private key part of an SSH key pair.
The public key part should be added to the authorized_keys
file on the server that receives the deployment.
More info for SSH keys: https://www.ssh.com/ssh/public-key-authentication
The keys should be generated using the PEM format. You can use this command
ssh-keygen -m PEM -t rsa -b 4096
REMOTE_HOST
[required]
2. eg: mydomain.com
REMOTE_USER
[required]
3. eg: myusername
REMOTE_PORT
(optional, default '22')
4. eg: '59184'
ARGS
(optional, default '-rltgoDzvO')
5. For any initial/required rsync flags, eg: -avzr --delete
SOURCE
(optional, default '')
6. The source directory, path relative to $GITHUB_WORKSPACE
root, eg: dist/
TARGET
(optional, default '/home/REMOTE_USER/')
7. The target directory
EXCLUDE
(optional, default '')
8. path to exclude separated by ,
, ie: /dist/, /node_modules/
Usage
!!! Please use latest version, Readme file is just an example, eg: [email protected]
- name: Deploy to Staging server
uses: easingthemes/[email protected]
env:
SSH_PRIVATE_KEY: ${{ secrets.SERVER_SSH_KEY }}
ARGS: "-rltgoDzvO"
SOURCE: "dist/"
REMOTE_HOST: ${{ secrets.REMOTE_HOST }}
REMOTE_USER: ${{ secrets.REMOTE_USER }}
TARGET: ${{ secrets.REMOTE_TARGET }}
EXCLUDE: "/dist/, /node_modules/"
Example usage in workflow
name: Node CI
on: [push]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/[email protected]
- name: Install Node.js
uses: actions/[email protected]
with:
node-version: '10.x'
- name: Install npm dependencies
run: npm install
- name: Run build task
run: npm run build --if-present
- name: Deploy to Server
uses: easingthemes/[email protected]
env:
SSH_PRIVATE_KEY: ${{ secrets.SERVER_SSH_KEY }}
ARGS: "-rltgoDzvO --delete"
SOURCE: "dist/"
REMOTE_HOST: ${{ secrets.REMOTE_HOST }}
REMOTE_USER: ${{ secrets.REMOTE_USER }}
TARGET: ${{ secrets.REMOTE_TARGET }}
EXCLUDE: "/dist/, /node_modules/"
Disclaimer
Check your keys. Check your deployment paths. And use at your own risk.