Skip to content

disorientations/rsync-deployments

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 

Repository files navigation

rsync deployments GitHub Action

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.

Example usage

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 }} 

Inputs

USER_AND_HOST

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]

DEST

Mandatory. Deployment destination path.

jobs:
  deploy:
    runs-on: ubuntu-latest
    steps:
      - # ...
      - uses: contention/rsync-deployments@master
        with:
          # ...
          DEST: /path/to/target

SRC

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/

RSYNC_OPTIONS

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*'

Required SECRET

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.

Disclaimer

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.

About

GitHub Action for deploying code via rsync over ssh

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Dockerfile 65.9%
  • Shell 34.1%