Manual deploys are slow and error-prone. With GitHub Actions you can deploy to your VPS automatically every time you push — a simple CI/CD pipeline.

1. Add an SSH deploy key

Generate a key pair, add the public key to your VPS user's authorized_keys, and store the private key as a GitHub secret (e.g. SSH_KEY). Store the host and username as secrets too.

2. Create the workflow

Add .github/workflows/deploy.yml:

name: Deploy
on:
  push:
    branches: [ main ]
jobs:
  deploy:
    runs-on: ubuntu-latest
    steps:
      - uses: appleboy/ssh-action@v1
        with:
          host: ${{ secrets.HOST }}
          username: ${{ secrets.USER }}
          key: ${{ secrets.SSH_KEY }}
          script: |
            cd /var/www/myapp
            git pull
            ./venv/bin/pip install -r requirements.txt
            sudo systemctl restart myapp

3. Push and watch

Every push to main now pulls the latest code, installs dependencies and restarts your service — automatically. Add tests before the deploy step to catch problems before they ship.