name: Notification Worker Cron

on:
  schedule:
    # Executa a cada 5 minutos
    - cron: "*/5 * * * *"
  workflow_dispatch: # Permite execução manual

jobs:
  process-notifications:
    runs-on: ubuntu-latest

    steps:
      - name: Process notification queue
        run: |
          curl -X POST \
            -H "Authorization: Bearer ${{ secrets.SUPABASE_SERVICE_ROLE_KEY }}" \
            -H "Content-Type: application/json" \
            https://etblfypcxxtvvuqjkrgd.supabase.co/functions/v1/notifications-worker
        continue-on-error: true

      - name: Log completion
        run: echo "Notification worker completed at $(date)"
