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
48 - name: Sync provider models
49 id: provider
50 continue-on-error: true
51 run: pnpm exec tsx scripts/sync-provider-models.ts
52
53 - name: Format
54 run: pnpm format
55
56 - name: Check for package changes
57 id: changes
58 run: |
59 if git diff --quiet -- packages/; then
60 echo "changed=false" >> $GITHUB_OUTPUT
61 else
62 echo "changed=true" >> $GITHUB_OUTPUT
63 fi
64
65 - name: Commit and force-push
66 if: steps.changes.outputs.changed == 'true'
67 run: |
68 git config user.name "github-actions[bot]"
69 git config user.email "github-actions[bot]@users.noreply.github.com"
70 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/
71 git commit -m "chore: sync model metadata"
72 # GITHUB_TOKEN pushes do not start the PR Test / E2E workflows.
73 # After this job, a maintainer must run those checks from the
74 # Actions tab or push an empty commit to automated/sync-models.
75 git push --force origin HEAD:automated/sync-models
76 env:
77 GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
78
79 - name: Create or update PR
80 if: steps.changes.outputs.changed == 'true'
81 env:
82 GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
83 shell: bash
84 run: |
85 BRANCH="automated/sync-models"
86 EXISTING_PR=$(gh pr list --head "$BRANCH" --base main --json number --jq '.[0].number' 2>/dev/null || true)
87
88 if [ -z "$EXISTING_PR" ] || [ "$EXISTING_PR" = "null" ]; then
89 BODY=$(cat <<'PRBODY'
90 Automated daily sync of model metadata from OpenRouter, Vercel AI Gateway, Lovable AI Gateway, and modelschemas (ElevenLabs text-to-speech, music, sound effects, and voice design).
91
92 - Fetches the latest model list from OpenRouter (chat + `GET /api/v1/videos/models`)
93 - Fetches the latest model list from Vercel AI Gateway
94 - Fetches the latest model list from Lovable AI Gateway
95 - Converts to the internal adapter format
96 - Syncs provider-specific model metadata for affected packages
97 - Inserts new ElevenLabs text-to-speech, music, sound-effect, and voice-design models from modelschemas
98 - Creates a patch changeset for all changed packages
99 PRBODY
100 )
101 gh pr create \
102 --title "chore: sync model metadata" \
103 --body "$BODY" \
104 --base main \
105 --head "$BRANCH"
106 fi
107
108 - name: Fail if any sync step failed
109 if: >-
110 steps.fetch.outcome == 'failure' ||
111 steps.convert.outcome == 'failure' ||
112 steps.elevenlabs.outcome == 'failure' ||
113 steps.provider.outcome == 'failure'
114 run: |
115 echo "::error::A model sync step failed. Passing steps were still committed."
116 exit 1
117
118 - name: Open or update failure issue
119 if: failure()
120 env:
121 GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
122 RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
123 OUTCOMES: >-
124 fetch=${{ steps.fetch.outcome }},
125 convert=${{ steps.convert.outcome }},
126 elevenlabs=${{ steps.elevenlabs.outcome }},
127 provider=${{ steps.provider.outcome }}
128 shell: bash
129 run: |
130 gh label create sync-models --color B60205 --description "Daily model sync failures" --force
131 BODY=$(printf '%s\n' \
132 "🚨 Sync Model Metadata failed on $(date -u +%F)." \
133 "" \
134 "Run: $RUN_URL" \
135 "Step outcomes: $OUTCOMES" \
136 "" \
137 "Steps that passed were still committed to \`automated/sync-models\`. Close this issue when the sync is green again.")
138 ISSUE=$(gh issue list --label sync-models --state open --json number --jq '.[0].number // empty')
139 if [ -n "$ISSUE" ]; then
140 gh issue comment "$ISSUE" --body "$BODY"
141 else
142 gh issue create --label sync-models \
143 --title "🚨🚨🚨 DAILY MODEL SYNC IS FAILING 🚨🚨🚨 Model updates are NOT landing" \
144 --body "$BODY"
145 fi