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 issues: write # failure alert issue
16
17jobs:
18 sync:
19 name: Sync Models
20 runs-on: ubuntu-latest
21 steps:
22 - name: Checkout
23 uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
24 with:
25 fetch-depth: 0
26 persist-credentials: true # sync job pushes generated model updates
27
28 - name: Setup Tools
29 uses: TanStack/config/.github/setup@190f659075ff0845850e330883eb26d7ffd0671f # main
30
31 # Each sync runs as its own step so one provider failing does not block
32 # the others. Whatever succeeded is still committed, then the job fails.
33 - name: Fetch gateway models
34 id: fetch
35 continue-on-error: true
36 run: pnpm generate:models:fetch
37
38 - name: Convert gateway models
39 id: convert
40 continue-on-error: true
41 run: pnpm regenerate:models
42
43 - name: Sync ElevenLabs models
44 id: elevenlabs
45 continue-on-error: true
46 run: pnpm generate:models:elevenlabs
47 env:
48 MODELSCHEMAS_API_KEY: ${{ secrets.MODELSCHEMAS_API_KEY }}
49
50 - name: Sync provider models
51 id: provider
52 continue-on-error: true
53 run: pnpm exec tsx scripts/sync-provider-models.ts
54 env:
55 MODELSCHEMAS_API_KEY: ${{ secrets.MODELSCHEMAS_API_KEY }}
56
57 - name: Format
58 run: pnpm format
59
60 - name: Check for package changes
61 id: changes
62 run: |
63 if git diff --quiet -- packages/; then
64 echo "changed=false" >> $GITHUB_OUTPUT
65 else
66 echo "changed=true" >> $GITHUB_OUTPUT
67 fi
68
69 - name: Commit and force-push
70 if: steps.changes.outputs.changed == 'true'
71 run: |
72 git config user.name "github-actions[bot]"
73 git config user.email "github-actions[bot]@users.noreply.github.com"
74 git add packages/ scripts/openrouter.models.json scripts/openrouter.video-models.json scripts/vercel-gateway.models.json scripts/lovable-gateway.models.json scripts/llmgateway.models.json scripts/neon.models.json scripts/.sync-models-last-run .changeset/
75 git commit -m "chore: sync model metadata"
76 # GITHUB_TOKEN pushes do not start the PR Test / E2E workflows.
77 # After this job, a maintainer must run those checks from the
78 # Actions tab or push an empty commit to automated/sync-models.
79 git push --force origin HEAD:automated/sync-models
80 env:
81 GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
82
83 - name: Create or update PR
84 if: steps.changes.outputs.changed == 'true'
85 env:
86 GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
87 shell: bash
88 run: |
89 BRANCH="automated/sync-models"
90 EXISTING_PR=$(gh pr list --head "$BRANCH" --base main --json number --jq '.[0].number' 2>/dev/null || true)
91
92 if [ -z "$EXISTING_PR" ] || [ "$EXISTING_PR" = "null" ]; then
93 BODY=$(cat <<'PRBODY'
94 Automated daily sync of model metadata from OpenRouter, Vercel AI Gateway, Lovable AI Gateway, LLM Gateway, Neon AI Gateway, and modelschemas (native provider models, plus ElevenLabs text-to-speech, music, sound effects, and voice design).
95
96 - Fetches the latest model list from OpenRouter (chat + `GET /api/v1/videos/models`)
97 - Fetches the latest model list from Vercel AI Gateway
98 - Fetches the latest model list from Lovable AI Gateway
99 - Fetches the latest model list from LLM Gateway (`GET /v1/models`)
100 - Fetches the latest model list from Neon AI Gateway
101 - Converts to the internal adapter format
102 - Inserts new native-provider models from modelschemas (`@modelschemas/client`)
103 - Inserts new ElevenLabs text-to-speech, music, sound-effect, and voice-design models from modelschemas
104 - Creates a patch changeset for all changed packages
105 PRBODY
106 )
107 gh pr create \
108 --title "chore: sync model metadata" \
109 --body "$BODY" \
110 --base main \
111 --head "$BRANCH"
112 fi
113
114 - name: Fail if any sync step failed
115 if: >-
116 steps.fetch.outcome == 'failure' ||
117 steps.convert.outcome == 'failure' ||
118 steps.elevenlabs.outcome == 'failure' ||
119 steps.provider.outcome == 'failure'
120 run: |
121 echo "::error::A model sync step failed. Passing steps were still committed."
122 exit 1
123
124 - name: Open or update failure issue
125 if: failure()
126 env:
127 GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
128 RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
129 OUTCOMES: >-
130 fetch=${{ steps.fetch.outcome }},
131 convert=${{ steps.convert.outcome }},
132 elevenlabs=${{ steps.elevenlabs.outcome }},
133 provider=${{ steps.provider.outcome }}
134 shell: bash
135 run: |
136 gh label create sync-models --color B60205 --description "Daily model sync failures" --force
137 BODY=$(printf '%s\n' \
138 "🚨 Sync Model Metadata failed on $(date -u +%F)." \
139 "" \
140 "Run: $RUN_URL" \
141 "Step outcomes: $OUTCOMES" \
142 "" \
143 "Steps that passed were still committed to \`automated/sync-models\`. Close this issue when the sync is green again.")
144 ISSUE=$(gh issue list --label sync-models --state open --json number --jq '.[0].number // empty')
145 if [ -n "$ISSUE" ]; then
146 gh issue comment "$ISSUE" --body "$BODY"
147 else
148 gh issue create --label sync-models \
149 --title "🚨🚨🚨 DAILY MODEL SYNC IS FAILING 🚨🚨🚨 Model updates are NOT landing" \
150 --body "$BODY"
151 fi