Skip to content

Update Vercel Models #24

Update Vercel Models

Update Vercel Models #24

name: Update Vercel Models
on:
schedule:
# Run every Monday to Friday at 8:00 AM Pacific Time (4:00 PM UTC)
- cron: '0 16 * * 1,3,5'
workflow_dispatch:
permissions:
contents: write
pull-requests: write
jobs:
update-models:
name: Update Vercel Models
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- name: Checkout Repository
uses: actions/checkout@v4
with:
ref: dev
fetch-depth: 0
- name: Setup Bun
uses: oven-sh/setup-bun@v1
with:
bun-version: latest
- name: Install Dependencies
run: bun install
- name: Sync with upstream
run: |
git config --global user.name 'github-actions[bot]'
git config --global user.email '41898282+github-actions[bot]@users.noreply.github.com'
git remote add upstream https://github.com/anomalyco/models.dev.git || true
git fetch upstream
git merge upstream/dev --no-edit
git push origin dev
- name: Generate Vercel models
run: bun run vercel:generate --new-only
- name: Validate models
run: bun run validate
- name: Check for changes
id: check-changes
run: |
if [ -z "$(git status --porcelain providers/vercel/)" ]; then
echo "has-changes=false" >> "$GITHUB_OUTPUT"
echo "No changes detected in Vercel models"
else
echo "has-changes=true" >> "$GITHUB_OUTPUT"
echo "Changes detected in Vercel models"
git status --porcelain providers/vercel/
fi
- name: Create branch and commit changes
if: steps.check-changes.outputs.has-changes == 'true'
id: create-branch
run: |
BRANCH_NAME="update-vercel-models-$(date +%Y%m%d-%H%M)"
git config --global user.name 'github-actions[bot]'
git config --global user.email '41898282+github-actions[bot]@users.noreply.github.com'
git checkout -b "$BRANCH_NAME" upstream/dev
git add $(git ls-files --others --exclude-standard -- providers/vercel/) 2>/dev/null; true
git add $(git ls-files --deleted -- providers/vercel/) 2>/dev/null; true
git commit -m "chore(vercel): update Vercel model definitions
Auto-generated by weekly workflow from Vercel AI Gateway API.
Co-Authored-By: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>"
git push origin "$BRANCH_NAME"
echo "branch-name=$BRANCH_NAME" >> "$GITHUB_OUTPUT"
- name: Create Pull Request
if: steps.check-changes.outputs.has-changes == 'true'
id: create-pr
run: |
PR_TITLE="Update Vercel models"
PR_BODY="## Summary
Automated weekly sync of Vercel model definitions from the [AI Gateway API](https://ai-gateway.vercel.sh/v1/models).
See commit for details on models added, updated, or removed.
## Test plan
- \`bun validate\` passes
---
🤖 Auto-generated by [\`update-vercel-models\`](.github/workflows/update-vercel-models.yml)"
PR_URL=$(gh pr create \
--repo "anomalyco/models.dev" \
--title "$PR_TITLE" \
--body "$PR_BODY" \
--base dev \
--head "${{ github.repository_owner }}:${{ steps.create-branch.outputs.branch-name }}")
PR_NUMBER=$(echo "$PR_URL" | grep -oE '[0-9]+$')
echo "pr-url=$PR_URL" >> "$GITHUB_OUTPUT"
echo "pr-number=$PR_NUMBER" >> "$GITHUB_OUTPUT"
echo "pr-title=$PR_TITLE" >> "$GITHUB_OUTPUT"
echo "PR created: $PR_URL"
env:
GH_TOKEN: ${{ secrets.UPSTREAM_GITHUB_TOKEN }}
- name: No changes
if: steps.check-changes.outputs.has-changes == 'false'
run: |
echo "No changes detected. Vercel models are already up to date."
- name: Send Slack notification
if: always()
run: |
if [ -z "$VERCEL_SLACK_WEBHOOK_URL" ]; then
echo "Slack webhook not configured. Skipping Slack notification."
echo "To enable Slack notifications, add VERCEL_SLACK_WEBHOOK_URL secret to repository settings."
exit 0
fi
if [ "$HAS_CHANGES" == "true" ] && [ "$PR_CREATED" == "success" ]; then
curl "$VERCEL_SLACK_WEBHOOK_URL" -X POST -H "Content-Type: application/json" \
-d "{\"channel_id\": \"$VERCEL_SLACK_CHANNEL\", \"title\": \"$PR_TITLE\", \"reviewer\": \"$SLACK_USER_ID\", \"url\": \"$PR_URL\"}"
elif [ "$HAS_CHANGES" == "true" ] && [ "$PR_CREATED" != "success" ]; then
echo "PR creation failed. Skipping Slack notification."
fi
env:
VERCEL_SLACK_WEBHOOK_URL: ${{ secrets.VERCEL_SLACK_WEBHOOK_URL }}
HAS_CHANGES: ${{ steps.check-changes.outputs.has-changes }}
PR_CREATED: ${{ steps.create-pr.outcome }}
PR_TITLE: "Update Vercel models (for Models.dev)"
PR_URL: ${{ steps.create-pr.outputs.pr-url }}
VERCEL_SLACK_CHANNEL: "C099VQB75TP"
SLACK_USER_ID: "U09LK204TPZ"