Skip to content

Instantly share code, notes, and snippets.

@maxfenton
Created October 1, 2025 15:19
Show Gist options
  • Select an option

  • Save maxfenton/0f05b7d8e8db7a2b39f22513b239c488 to your computer and use it in GitHub Desktop.

Select an option

Save maxfenton/0f05b7d8e8db7a2b39f22513b239c488 to your computer and use it in GitHub Desktop.
Github Actions workflow for deploying a Kirby site to shared hosting with rsync
name: Staging Deployment
on:
push:
branches: [ main ]
jobs:
build:
runs-on: ubuntu-latest
defaults:
run:
shell: bash
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 2
# Set up Node.js
- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: '22'
# Set up PHP
- name: Set up PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.3'
# Install Node.js dependencies
- name: Install Node.js dependencies
run: npm ci && npm run build
# Install Composer dependencies
- name: Install Composer dependencies
run: composer install --no-dev --optimize-autoloader
# Rsync/SFTP Deploy
- name: Deploy via rsync over SSH
uses: Burnett01/[email protected]
with:
switches: -avzr --delete --exclude='.ddev/' --exclude='.env.example' --exclude='.github/' --exclude='.git/' --exclude='.gitignore' --exclude='.DS_Store' --exclude='content/' --exclude='storage/' --exclude='site/accounts/' --exclude='site/cache/' --exclude='node_modules/'
path: .
remote_path: staging.maxfenton.com/
remote_host: ${{ secrets.STAGING_SERVER }}
remote_user: ${{ secrets.STAGING_USER }}
remote_key: ${{ secrets.STAGING_SSH_KEY }}
remote_port: 22
@maxfenton
Copy link
Author

Add the three secrets (for each branch / environment) to the repo settings.

Add this file (or similar) to your project at .github/workflows/staging.yml

@maxfenton
Copy link
Author

This setup is for a Kirby site, but you can use it for anything and change the --exclude flags

This set of --excludes assumes:

  • You do not want to push content from local to production
  • You do want to occasionally rsync the content down from production to local and commit it to the repo as backup

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment