|
| 1 | +name: models-snapshot |
| 2 | + |
| 3 | +permissions: |
| 4 | + contents: write |
| 5 | + |
| 6 | +on: |
| 7 | + workflow_dispatch: |
| 8 | + schedule: |
| 9 | + - cron: "*/30 * * * *" |
| 10 | + |
| 11 | +concurrency: |
| 12 | + group: ${{ github.workflow }} |
| 13 | + cancel-in-progress: false |
| 14 | + |
| 15 | +jobs: |
| 16 | + refresh: |
| 17 | + if: github.repository == 'anomalyco/opencode' |
| 18 | + runs-on: blacksmith-4vcpu-ubuntu-2404 |
| 19 | + |
| 20 | + steps: |
| 21 | + - name: Checkout repository |
| 22 | + uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1 |
| 23 | + with: |
| 24 | + persist-credentials: false |
| 25 | + ref: v2 |
| 26 | + |
| 27 | + # The refresh script only needs `fetch`; skip the monorepo install. |
| 28 | + - name: Setup Bun |
| 29 | + uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2.2.0 |
| 30 | + with: |
| 31 | + bun-version-file: package.json |
| 32 | + |
| 33 | + - name: Setup git committer |
| 34 | + uses: ./.github/actions/setup-git-committer |
| 35 | + with: |
| 36 | + opencode-app-id: ${{ vars.OPENCODE_APP_ID }} |
| 37 | + opencode-app-secret: ${{ secrets.OPENCODE_APP_SECRET }} |
| 38 | + |
| 39 | + - name: Refresh snapshot |
| 40 | + run: bun packages/core/script/update-models-snapshot.ts |
| 41 | + |
| 42 | + - name: Commit changes |
| 43 | + run: | |
| 44 | + set -euo pipefail |
| 45 | +
|
| 46 | + FILE="packages/core/src/models-dev/snapshot.txt" |
| 47 | +
|
| 48 | + if [ -z "$(git status --short -- "$FILE")" ]; then |
| 49 | + echo "No changes to commit" |
| 50 | + echo "### models.dev snapshot" >> "$GITHUB_STEP_SUMMARY" |
| 51 | + echo "Status: no changes" >> "$GITHUB_STEP_SUMMARY" |
| 52 | + exit 0 |
| 53 | + fi |
| 54 | +
|
| 55 | + git add "$FILE" |
| 56 | + git commit -m "chore(core): refresh bundled models.dev snapshot" |
| 57 | +
|
| 58 | + git pull --rebase --autostash origin v2 |
| 59 | + git push origin HEAD:v2 --no-verify |
| 60 | +
|
| 61 | + echo "### models.dev snapshot" >> "$GITHUB_STEP_SUMMARY" |
| 62 | + echo "Status: committed $(git rev-parse --short HEAD)" >> "$GITHUB_STEP_SUMMARY" |