This GitHub Action deploys your GitHub Action Workspace, totally or partially, to a remote server via rsync over ssh.
This action would usually follow a build/test action which leaves deployable code in GITHUB_WORKSPACE
.
name: Checkout repo master branch and deploy to production
on:
push:
branches:
- master
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- uses: contention/rsync-deployments@master
with:
USER_AND_HOST: [email protected]
DEST: /path/to/target
env:
DEPLOY_KEY: ${{ secrets.SSH_PRIVATE_KEY }}
Mandatory. Deployment user and host, and should be in the format: [USER]@[HOST]
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- # ...
- uses: contention/rsync-deployments@master
with:
# ...
USER_AND_HOST: [email protected]
Mandatory. Deployment destination path.
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- # ...
- uses: contention/rsync-deployments@master
with:
# ...
DEST: /path/to/target
Optional. Change this to deploy a smaller subset of your GitHub workspace. Any value understood by rsync
is accepted. By default, the entire workspace is deployed.
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- # ...
- uses: contention/rsync-deployments@master
with:
# ...
SRC: _site/
Optional. Any initial/required rsync flags, as found in the Options Summary section of rsync manual.
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- # ...
- uses: contention/rsync-deployments@master
with:
# ...
RSYNC_OPTIONS: -avzr --delete --exclude node_modules --exclude '.git*'
This action needs a DEPLOY_KEY
secret variable. This should be the 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.
jobs:
# ...
deploy:
runs-on: ubuntu-latest
steps:
- # ...
- uses: contention/rsync-deployments@master
with:
# ...
env:
DEPLOY_KEY: ${{ secrets.SSH_PRIVATE_KEY }}
In this example, it is expected you create a new repo Settings › Secrets
named SSH_PRIVATE_KEY
, with the content of a private key, with access to the remote host you want to deploy to.
If you're using GitHub Actions, you'll probably already know that it's still in limited public beta, and GitHub advise against using Actions in production.
So, check your keys. Check your deployment paths. And use at your own risk.