-
-
Notifications
You must be signed in to change notification settings - Fork 183
76 lines (65 loc) · 2.29 KB
/
sync-models.yml
File metadata and controls
76 lines (65 loc) · 2.29 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
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
jobs:
sync:
name: Sync Models
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v6.0.2
with:
fetch-depth: 0
- name: Setup Tools
uses: TanStack/config/.github/setup@main
- name: Fetch and sync model metadata
run: pnpm generate:models
- 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.ts scripts/.sync-models-last-run .changeset/
git commit -m "chore: sync model metadata from OpenRouter"
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 the OpenRouter API.
- Fetches the latest model list from OpenRouter
- Converts to the internal adapter format
- Syncs provider-specific model metadata for affected packages
- Creates a patch changeset for all changed packages
PRBODY
)
gh pr create \
--title "chore: sync model metadata from OpenRouter" \
--body "$BODY" \
--base main \
--head "$BRANCH"
fi