name: Deploy Production

on:
  push:
    branches: [main]

jobs:
  deploy:
    runs-on: ubuntu-latest
    steps:
      - name: Deploy to Production
        run: |
          set -e
          echo "=== Deploying Shinkan to PRODUCTION ==="
          cd /home/lars/docker/shinkan
          git fetch origin main || git clone http://192.168.2.144:3000/Lars/shinkan-jinkendo.git .
          git reset --hard origin/main
          docker compose build --no-cache
          docker compose up -d
          sleep 5
          curl -sf http://localhost:8003/api/version && echo "✓ PROD API (direkt) healthy"
          curl -sf http://localhost:3003/api/version && echo "✓ PROD API über Frontend-Nginx (wie Browser) healthy"
          echo "=== Shinkan PROD Deploy complete ==="
