This repository was archived by the owner on Apr 15, 2026. It is now read-only.
Sync Upstream #16193
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Sync Upstream | |
| on: | |
| schedule: | |
| - cron: "0 */6 * * *" | |
| workflow_dispatch: | |
| permissions: | |
| contents: write | |
| issues: write | |
| jobs: | |
| sync: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| token: ${{ secrets.GH_PAT }} | |
| fetch-depth: 0 | |
| - name: Configure git | |
| run: | | |
| git config user.name "github-actions[bot]" | |
| git config user.email "github-actions[bot]@users.noreply.github.com" | |
| - name: Add upstream remote | |
| run: | | |
| git remote add upstream https://github.com/anomalyco/models.dev.git || true | |
| git fetch upstream dev | |
| - name: Check for new commits | |
| id: check | |
| run: | | |
| BEHIND=$(git rev-list HEAD..upstream/dev --count) | |
| echo "behind=$BEHIND" >> "$GITHUB_OUTPUT" | |
| if [ "$BEHIND" -eq 0 ]; then | |
| echo "Already up to date" | |
| else | |
| echo "Found $BEHIND new upstream commits" | |
| COMMITS=$(git log HEAD..upstream/dev --oneline --no-merges | head -20) | |
| echo "commits<<EOF" >> "$GITHUB_OUTPUT" | |
| echo "$COMMITS" >> "$GITHUB_OUTPUT" | |
| echo "EOF" >> "$GITHUB_OUTPUT" | |
| fi | |
| - name: Merge upstream | |
| if: steps.check.outputs.behind != '0' | |
| id: merge | |
| run: | | |
| if git merge upstream/dev --no-edit -X theirs; then | |
| echo "status=success" >> "$GITHUB_OUTPUT" | |
| else | |
| echo "status=conflict" >> "$GITHUB_OUTPUT" | |
| CONFLICTS=$(git diff --name-only --diff-filter=U) | |
| echo "conflicts<<EOF" >> "$GITHUB_OUTPUT" | |
| echo "$CONFLICTS" >> "$GITHUB_OUTPUT" | |
| echo "EOF" >> "$GITHUB_OUTPUT" | |
| git merge --abort | |
| fi | |
| - name: Push changes | |
| if: steps.merge.outputs.status == 'success' | |
| run: git push origin dev | |
| - name: Trigger deploy | |
| if: steps.merge.outputs.status == 'success' | |
| run: | | |
| gh api repos/${{ github.repository }}/dispatches \ | |
| -f event_type=sync-completed | |
| env: | |
| GH_TOKEN: ${{ secrets.GH_PAT }} | |
| - name: Ensure labels exist | |
| if: steps.merge.outputs.status == 'conflict' | |
| env: | |
| GH_TOKEN: ${{ secrets.GH_PAT }} | |
| run: | | |
| for label in sync conflict automated; do | |
| gh label create "$label" --repo "${{ github.repository }}" --force --color "ededed" 2>/dev/null || true | |
| done | |
| - name: Create conflict issue and assign Copilot | |
| if: steps.merge.outputs.status == 'conflict' | |
| run: | | |
| TITLE="🔀 Upstream sync conflict detected" | |
| BODY="## Merge Conflict with upstream/dev | |
| **Upstream commits to merge:** ${{ steps.check.outputs.behind }} | |
| ### New upstream commits | |
| \`\`\` | |
| ${{ steps.check.outputs.commits }} | |
| \`\`\` | |
| ### Conflicting files | |
| \`\`\` | |
| ${{ steps.merge.outputs.conflicts }} | |
| \`\`\` | |
| ### Instructions | |
| Resolve these merge conflicts while preserving our custom models (gemini-3.1-pro, opus-4.6, gpt-5.2-codex, etc.). | |
| Merge upstream/dev into dev using \`-X theirs\` for non-provider files, but keep our additions in \`providers/\`. | |
| After resolving, ensure \`api.json\` still includes all custom models." | |
| ISSUE_URL=$(gh issue create --repo "${{ github.repository }}" \ | |
| --title "$TITLE" \ | |
| --body "$BODY" \ | |
| --label "sync,conflict") | |
| ISSUE_NUM=$(echo "$ISSUE_URL" | grep -oP '\d+$') | |
| # Get issue and repo node IDs for GraphQL Copilot assignment | |
| ISSUE_NODE_ID=$(gh api "repos/${{ github.repository }}/issues/${ISSUE_NUM}" --jq '.node_id') | |
| REPO_NODE_ID=$(gh api "repos/${{ github.repository }}" --jq '.node_id') | |
| # Assign Copilot with Claude partner agent | |
| INSTRUCTIONS="Resolve this merge conflict. Preserve our custom models in providers/ (github-copilot with 22 models including claude-opus-4.6, gemini-3.1-pro, gpt-5.2-codex; google provider with gemini-3.1-pro, gemini-3-flash-preview, gemini-3-pro-preview). Use -X theirs for non-provider files. Ensure api.json generation still works. Create a fix PR." | |
| gh api graphql \ | |
| -H "GraphQL-Features: issues_copilot_assignment_api_support,coding_agent_model_selection" \ | |
| -f query='mutation($issue: ID!, $bot: ID!, $repo: ID!, $ref: String!, $instructions: String!, $agent: String!, $model: String!) { addAssigneesToAssignable(input: { assignableId: $issue, assigneeIds: [$bot], agentAssignment: { targetRepositoryId: $repo, baseRef: $ref, customInstructions: $instructions, customAgent: $agent, model: $model } }) { assignable { ... on Issue { number assignees(first: 5) { nodes { login } } } } } }' \ | |
| -f issue="$ISSUE_NODE_ID" \ | |
| -f bot="BOT_kgDOC9w8XQ" \ | |
| -f repo="$REPO_NODE_ID" \ | |
| -f ref="dev" \ | |
| -f instructions="$INSTRUCTIONS" \ | |
| -f agent="claude" \ | |
| -f model="" | |
| echo "Created conflict issue #${ISSUE_NUM} and assigned Copilot (Claude): ${ISSUE_URL}" | |
| env: | |
| GH_TOKEN: ${{ secrets.GH_PAT }} |