name: Update Providers

on:
  schedule:
    - cron: "0 2 * * *" # Run nightly at 2 AM UTC
  workflow_dispatch: # Allow manual triggering

jobs:
  update-schema:
    runs-on: ubuntu-latest
    permissions:
      contents: write
    steps:
      - uses: actions/checkout@v6
        with:
          token: ${{ secrets.GITHUB_TOKEN }}
      - uses: actions/setup-go@v6
        with:
          go-version-file: go.mod
      - name: Generate provider configurations
        run: |
          go run ./cmd/copilot/main.go
          go run ./cmd/openrouter/main.go
          go run ./cmd/synthetic/main.go
          # we need to add this back when we know that the providers/models all work
          # go run ./cmd/huggingface/main.go
      - uses: stefanzweifel/git-auto-commit-action@04702edda442b2e678b25b537cec683a1493fcb9 # v5
        with:
          commit_message: "chore: auto-update generated files"
          branch: main
          commit_user_name: Charm
          commit_user_email: 124303983+charmcli@users.noreply.github.com
          commit_author: Charm <124303983+charmcli@users.noreply.github.com>
