name: Deploy Production

on:
  push:
    branches: [main]

jobs:
  deploy:
    runs-on: ubuntu-latest
    steps:
      - name: Deploy to Production
        run: |
          set -e
          echo "=== Deploying to PRODUCTION ==="
          cd /home/lars/docker/bodytrack
          # Arbeitskopie = exakt origin/main (vermeidet Abbruch bei lokalem package-lock o. ä.)
          git fetch origin main
          git reset --hard origin/main
          docker compose -f docker-compose.yml build --no-cache
          docker compose -f docker-compose.yml up -d
          sleep 5
          curl -sf http://localhost:8002/api/auth/status && echo "✓ PROD API healthy"
          echo "=== PROD Deploy complete ==="
