GitHub Action
rsync deployments
This GitHub Action deploys files in GITHUB_WORKSPACE
to a folder on a server via rsync over ssh.
This action would usually follow a build/test action which leaves deployable code in GITHUB_WORKSPACE
.
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.
This action requires six inputs:
-
FLAGS
for any initial/required rsync flags, eg:-avzr --delete
-
EXCLUDES
for any--exclude
flags and directory pairs, eg:--exclude .htaccess --exclude /uploads/
. Use""
if none required. -
USER
for the server user, eg:deploybot
-
HOST
for the deployment target, eg:myserver.com
-
LOCALPATH
for the local path to sync, eg:/dist/
-
REMOTEPATH
for the remote path to sync, eg:/srv/myapp/public/htdocs/
name: Deploy to production
on:
push:
branches:
- master
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: contention/rsync-deployments@v2.0.0
with:
FLAGS: -avzr --delete
EXCLUDES: --exclude .htaccess --exclude /uploads/
USER deploybot
HOST: myserver.com
LOCALPATH: /dist/
REMOTEPATH: /srv/myapp/public/htdocs/
DEPLOY_KEY: ${{ secrets.DEPLOY_KEY }}
Check your keys. Check your deployment paths. Check your flags. And use at your own risk.