name: VYNDR Nightly Resolution

on:
  schedule:
    - cron: '0 7 * * *'  # 2am ET
  workflow_dispatch:

jobs:
  nightly-resolution:
    runs-on: ubuntu-latest
    defaults:
      run:
        working-directory: src/services/python

    steps:
      - uses: actions/checkout@v4

      - uses: actions/setup-python@v5
        with:
          python-version: '3.11'

      - name: Install dependencies
        run: pip install -r requirements.txt

      - name: Run nightly resolution
        env:
          SUPABASE_URL: ${{ secrets.SUPABASE_URL }}
          SUPABASE_SERVICE_KEY: ${{ secrets.SUPABASE_SERVICE_KEY }}
          ODDS_API_KEY: ${{ secrets.ODDS_API_KEY }}
          SHADOW_MODE: ${{ vars.SHADOW_MODE }}
        run: |
          python -c "import sys; sys.path.insert(0, '.'); from blueprints.resolution import nightly_resolution_job; from datetime import date, timedelta; nightly_resolution_job((date.today() - timedelta(days=1)).isoformat())"
