name: Build and Deploy DAVE | DMGs Site

on:
  push:
    branches: [main]

jobs:
  deploy:
    runs-on: ubuntu-latest
    timeout-minutes: 10
    steps:
      - name: Checkout code
        uses: actions/checkout@v4

      - name: Install dependencies
        run: |
          export PATH="/home/deploy/.local/share/fnm/aliases/default/bin:$PATH"
          corepack enable
          pnpm install --no-frozen-lockfile

      - name: Build
        run: |
          export PATH="/home/deploy/.local/share/fnm/aliases/default/bin:$PATH"
          corepack enable
          SKIP_KEYSTATIC=true pnpm run build

      - name: Deploy
        run: |
          rsync -a --delete dist/ /var/www/dave-dmg.de/blog/
          echo "Deployed at $(date)"
