Skip to content

Hugo CI/CD🔗

Secrets (Repository → Settings → Secrets → Actions)🔗

  • SSH_HOST = endershollow.com
  • SSH_USER = webdeploy
  • SSH_PRIVATE_KEY = contents of your private key

Windows: Generate an SSH key for deploy🔗

ssh-keygen -t ed25519 -C "webdeploy@endershollow" -f "$env:USERPROFILE\.ssh\id_ed25519_webdeploy"
# Copy the public key to the server user:
#   type $env:USERPROFILE\.ssh\id_ed25519_webdeploy.pub
# On the VPS:
#   mkdir -p /home/webdeploy/.ssh
#   echo "ssh-ed25519 AAAA..." >> /home/webdeploy/.ssh/authorized_keys
#   chown -R webdeploy:webdeploy /home/webdeploy/.ssh
#   chmod 700 /home/webdeploy/.ssh
#   chmod 600 /home/webdeploy/.ssh/authorized_keys

Workflow🔗

.github/workflows/deploy.yml:

name: Deploy Hugo Site
on:
  push:
    branches: [ main ]
jobs:
  deploy:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - name: Setup Hugo
        uses: peaceiris/actions-hugo@v2
        with:
          hugo-version: "0.129.0"
      - name: Build
        run: hugo --minify
      - name: Rsync to VPS
        uses: burnett01/rsync-deployments@6.0.0
        with:
          path: public/
          remote_path: /srv/www/endershollow/
          remote_host: ${{ secrets.SSH_HOST }}
          remote_user: ${{ secrets.SSH_USER }}
          remote_key:  ${{ secrets.SSH_PRIVATE_KEY }}

Troubleshooting🔗

  • Action green but site unchanged → browser cache (Ctrl+F5), or verify /srv/www/endershollow/ timestamps.
  • Error: permission denied on rsync → ensure /srv/www/endershollow/ is owned by webdeploy or group-writable.