Save as .github/workflows/deploy.yml and add the four secrets (VPS_HOST, VPS_USER, VPS_SSH_KEY, DEPLOY_PATH). The full walkthrough, including creating the key, is in the guide on deploying a WordPress theme with GitHub Actions.
name: Deploy
on:
push:
branches: [master]
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: appleboy/ssh-action@v1.0.3
with:
host: ${{ secrets.VPS_HOST }}
username: ${{ secrets.VPS_USER }}
key: ${{ secrets.VPS_SSH_KEY }}
script: |
set -e
cd "${{ secrets.DEPLOY_PATH }}"
git fetch origin master
git reset --hard origin/master
set -e stops the script at the first failing command, so a failed fetch can’t be reported as a successful deploy.