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