name: Deploy

on:
  push:
    branches: [main]

jobs:
  deploy:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4

      - name: Deploy pulse-web
        run: |
          cd /opt/digital-home/pulse-web
          docker compose up -d --build
          echo "Waiting for container..."
          sleep 5
          STATUS=$(docker inspect --format='{{.State.Status}}' pulse-web 2>/dev/null || echo "unknown")
          echo "Container status: $STATUS"
          if [ "$STATUS" != "running" ]; then
            echo "::error::Container is not running after deploy"
            docker logs pulse-web --tail=20
            exit 1
          fi
          echo "Deploy successful!"
