Continuous integration workflows are standard practice now: code lives in Git, and CI takes care of running tests, sending notifications and shipping builds. That last part — Continuous Deployment — has traditionally meant paying for a service, but GitHub Actions makes it free. What follows is a setup that assumes no dedicated DevOps specialist, using SSH and rsync to push a built WordPress theme to production.

How the pipeline works

The model is straightforward. You commit to a shared remote repository on GitHub, and each push triggers automated tasks on a remote server — linting, concatenation, minification, image optimization and similar build steps. CD then delivers the verified output to the production web server.

There are several delivery routes: FTP, SSH, or shipping containers into an infrastructure. FTP is available with virtually every shared hosting package but is slow and unreliable when transferring many files. Containers suit complex applications but bring their own infrastructure overhead. SSH is the middle ground — fast, safe, flexible, and supported by many hosting plans. rsync, which syncs files between a source and a destination and transfers only files that are changed or missing at the destination, is the practical way to drive SSH deployments. It ships as standard on most popular Linux distributions, so installation is rarely needed.

Deploying with rsync

The minimal form is rsync SRC DEST. For deployments, a handful of options matter:

  • -c — detect changes by checksum rather than modification time
  • -h — human-readable numbers in the output
  • -a — retain attributes and permissions and recurse into directories
  • -v — show status output
  • --delete — remove destination files no longer present in the source
  • --exclude — skip paths such as .git and node_modules

Combined with a remote target, the command looks like this:

rsync -chav --delete --exclude /.git/ --exclude /node_modules/ ./ [email protected]:/mydir

Running that locally works, but a controlled, clean-state environment is the point of CI — so the next step is moving it into a workflow.

Building the GitHub Actions workflow

GitHub Actions can run on any GitHub event. Rather than pulling an action from the marketplace, this example builds a custom workflow. In the repository's "Actions" tab, choose "Set up a workflow yourself"; the editor opens a .yaml template that gets committed to .github/workflows.

Saving this gives a workflow that checks out the repository and runs some echo commands. name makes status and results easy to follow later, and run holds the shell commands for each step.

Choosing a deployment trigger

In theory every commit to master is production-ready. In practice deployments need testing on the live server afterward, which has to happen on a schedule. One approach treats deploying only on workdays — not Fridays, and only before 4:00 pm — as best practice, so there is time to roll back or fix problems during business hours.

A branch reserved for deployments is an easy way to get manual-level control: merge master into it whenever you are ready to ship. Call the branch production, tell the team that pushes to it are only allowed from master, and do it like this:

git push origin master:production

Restricting the workflow trigger to that branch:

name: Deployment
on:
  push:
    branches: [ production ]

Verifying the build

This example assumes the Flynt WordPress starter theme, which manages dependencies via Composer and npm and ships a preconfigured build process. Other themes will likely need adjustments; if built assets are checked into the repository, everything except the checkout command can be skipped. The workflow ensures the required node version runs and installs dependencies before building:

jobs:
  deploy:
    runs-on: ubuntu-latest

    steps:
    - uses: actions/checkout@v2
    
    - uses: actions/setup-node@v2
      with:
        node-version: 12.x

    - name: Install dependencies
      run: |
        composer install -o
        npm install

    - name: Build
      run: npm run build

The Flynt build task requires, lints, compiles and transpiles Sass and JavaScript, then adds revisioning to assets so browser caches don't serve stale files. A failing build stops the workflow before a broken release can be deployed.

Server access and destination

rsync needs SSH access to the server. Three steps set that up:

  1. Generate a new SSH key, without a passphrase.
  2. Add the public key to ~/.ssh/authorized_keys on the production server.
  3. Add the private key to the repository as a secret named DEPLOY_KEY.

The sync step writes the key to a local file, adjusts file permissions and passes it to rsync. The destination must point at the theme directory on the production server; defining it as a variable makes reuse across projects easier.

- name: Sync
  env:
    dest: '[email protected]:/mydir/wp-content/themes/mytheme'
  run: |
    echo "${{secrets.DEPLOY_KEY}}" > deploy_key
    chmod 600 ./deploy_key
    rsync -chav --delete \
      -e 'ssh -i ./deploy_key -o StrictHostKeyChecking=no' \
      --exclude /deploy_key \
      --exclude /.git/ \
      --exclude /.github/ \
      --exclude /node_modules/ \
      ./ ${{env.dest}}

To deploy plugins or other theme-related files, change source and destination to the desired parent directory, review the excluded files, and check whether any build-process paths need adjusting.

Assembling the full workflow

All the pieces now need to run in sequence: trigger on each push to production, install dependencies, build and verify the code, then send the result to the server via rsync.

name: Deployment
on:
  push:
    branches: [ production ]
jobs:
  deploy:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v2
    - uses: actions/setup-node@v2
      with:
        node-version: 12.x
    - name: Install dependencies
      run: |
        composer install -o
        npm install
    - name: Build
      run: npm run build
    
    - name: Sync
      env:
        dest: '[email protected]:/mydir/wp-content/themes/mytheme'
      run: |
        echo "${{secrets.DEPLOY_KEY}}" > deploy_key
        chmod 600 ./deploy_key
        rsync -chav --delete \
          -e 'ssh -i ./deploy_key -o StrictHostKeyChecking=no' \
          --exclude /deploy_key \
          --exclude /.git/ \
          --exclude /.github/ \
          --exclude /node_modules/ \
          ./ ${{env.dest}}

Commit the changes, pull them into the local repository, and trigger a deployment by pushing master to the production branch:

git push origin master:production

Execution status is visible in the "Actions" tab: open the recent run and the "deploy" job, where green checkmarks indicate success. If something fails, the logs of the failed steps show what to fix.

The workflow file is reusable across projects. Further refinements worth considering: caching dependencies to speed up the workflow, activating WordPress maintenance mode while files sync, and clearing the site cache of a plugin such as Cache Enabler after deployment.