name: FastAPI People Sponsors

on:
  schedule:
    - cron: "0 6 1 * *"
  workflow_dispatch:
    inputs:
      debug_enabled:
        description: "Run the build with tmate debugging enabled (https://github.com/marketplace/actions/debugging-with-tmate)"
        required: false
        default: "false"

jobs:
  job:
    if: github.repository_owner == 'fastapi'
    runs-on: ubuntu-latest
    permissions:
      contents: write
    steps:
      - name: Dump GitHub context
        env:
          GITHUB_CONTEXT: ${{ toJson(github) }}
        run: echo "$GITHUB_CONTEXT"
      - uses: actions/checkout@v6
      - name: Set up Python
        uses: actions/setup-python@v6
        with:
          python-version-file: ".python-version"
      - name: Setup uv
        uses: astral-sh/setup-uv@v7
        with:
          enable-cache: true
          cache-dependency-glob: |
            pyproject.toml
            uv.lock
      - name: Install Dependencies
        run: uv sync --locked --no-dev --group github-actions
      # Allow debugging with tmate
      - name: Setup tmate session
        uses: mxschmitt/action-tmate@v3
        if: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.debug_enabled == 'true' }}
        with:
          limit-access-to-actor: true
      - name: FastAPI People Sponsors
        run: uv run ./scripts/sponsors.py
        env:
          SPONSORS_TOKEN: ${{ secrets.SPONSORS_TOKEN }}
          PR_TOKEN: ${{ secrets.FASTAPI_PR_TOKEN }}
