Open History to see the last commit
1name: Sync Model Metadata
2
3on:
4 schedule:
5 - cron: '0 6 * * *'
6 workflow_dispatch:
7
8concurrency:
9 group: ${{ github.workflow }}-${{ github.ref }}
10 cancel-in-progress: true
11
12permissions:
13 contents: write
14 pull-requests: write
15
16jobs:
17 sync:
18 name: Sync Models
19 runs-on: ubuntu-latest
20 steps:
21 - name: Checkout
22 uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
23 with:
24 fetch-depth: 0
25 persist-credentials: true # sync job pushes generated model updates
26
27 - name: Setup Tools
28 uses: TanStack/config/.github/setup@190f659075ff0845850e330883eb26d7ffd0671f # main
29
30 - name: Fetch and sync model metadata
31 run: pnpm generate:models
32
33 - name: Check for package changes
34 id: changes
35 run: |
36 if git diff --quiet -- packages/; then
37 echo "changed=false" >> $GITHUB_OUTPUT
38 else
39 echo "changed=true" >> $GITHUB_OUTPUT
40 fi
41
42 - name: Commit and force-push
43 if: steps.changes.outputs.changed == 'true'
44 run: |
45 git config user.name "github-actions[bot]"
46 git config user.email "github-actions[bot]@users.noreply.github.com"
47 git add packages/ scripts/openrouter.models.json scripts/openrouter.video-models.json scripts/vercel-gateway.models.json scripts/lovable-gateway.models.json scripts/.sync-models-last-run .changeset/
48 git commit -m "chore: sync model metadata"
49 # GITHUB_TOKEN pushes do not start the PR Test / E2E workflows.
50 # After this job, a maintainer must run those checks from the
51 # Actions tab or push an empty commit to automated/sync-models.
52 git push --force origin HEAD:automated/sync-models
53 env:
54 GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
55
56 - name: Create or update PR
57 if: steps.changes.outputs.changed == 'true'
58 env:
59 GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
60 shell: bash
61 run: |
62 BRANCH="automated/sync-models"
63 EXISTING_PR=$(gh pr list --head "$BRANCH" --base main --json number --jq '.[0].number' 2>/dev/null || true)
64
65 if [ -z "$EXISTING_PR" ] || [ "$EXISTING_PR" = "null" ]; then
66 BODY=$(cat <<'PRBODY'
67 Automated daily sync of model metadata from OpenRouter and Vercel AI Gateway.
68
69 - Fetches the latest model list from OpenRouter (chat + `GET /api/v1/videos/models`)
70 - Fetches the latest model list from Vercel AI Gateway
71 - Fetches the latest model list from Lovable AI Gateway
72 - Converts to the internal adapter format
73 - Syncs provider-specific model metadata for affected packages
74 - Creates a patch changeset for all changed packages
75 PRBODY
76 )
77 gh pr create \
78 --title "chore: sync model metadata" \
79 --body "$BODY" \
80 --base main \
81 --head "$BRANCH"
82 fi