Skip to content
truck

GitHub Action

rsync deployments

v2.0.0 Latest version

rsync deployments

truck

rsync deployments

Quick and simple method of deploying code to a webserver via rsync over ssh

Installation

Copy and paste the following snippet into your .yml file.

              

- name: rsync deployments

uses: contention/[email protected]

Learn more about this action in contention/rsync-deployments

Choose a version

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.

Required secrets

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.

Required inputs

This action requires six inputs:

  1. FLAGS for any initial/required rsync flags, eg: -avzr --delete

  2. EXCLUDES for any --exclude flags and directory pairs, eg: --exclude .htaccess --exclude /uploads/. Use "" if none required.

  3. USER for the server user, eg: deploybot

  4. HOST for the deployment target, eg: myserver.com

  5. LOCALPATH for the local path to sync, eg: /dist/

  6. REMOTEPATH for the remote path to sync, eg: /srv/myapp/public/htdocs/

Example usage

name: Deploy to production

on:
  push:
    branches:
      - master

jobs:
  deploy:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - uses: contention/[email protected]
        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 }}

REMINDER!

Check your keys. Check your deployment paths. Check your flags. And use at your own risk.