Repository navigation
59 lines (55 loc) · 2.04 KB
/
Copy pathrefresh-opencode-models.yml
File metadata and controls
59 lines (55 loc) · 2.04 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
name: Refresh OpenCode Go Models
on:
schedule:
- cron: '0 3 * * 1'
workflow_dispatch:
permissions:
contents: write
pull-requests: write
concurrency:
group: refresh-opencode-models
cancel-in-progress: false
jobs:
refresh:
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
with:
node-version: "22"
cache: npm
- run: npm ci
- name: Refresh OpenCode Go tier models from models.dev
run: node scripts/refresh-opencode-models.mjs --write
- name: Check for policy changes
id: diff
run: |
if git diff --quiet config/api-tier-models.json; then
echo "changed=false" >> "$GITHUB_OUTPUT"
else
echo "changed=true" >> "$GITHUB_OUTPUT"
fi
- name: Build and test updated policy
if: steps.diff.outputs.changed == 'true'
run: |
npm run build
npm test
- name: Open or update pull request
if: steps.diff.outputs.changed == 'true'
env:
GH_TOKEN: ${{ github.token }}
run: |
BRANCH="chore/refresh-opencode-go-models"
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git checkout -B "$BRANCH"
git add config/api-tier-models.json
git commit -m "chore: refresh OpenCode Go tier models from models.dev"
git push --force-with-lease origin "$BRANCH"
if ! gh pr list --head "$BRANCH" --state open --json number --jq '.[0].number' | grep -q '[0-9]'; then
gh pr create \
--head "$BRANCH" \
--base main \
--title "chore: refresh OpenCode Go tier models from models.dev" \
--body "Automated weekly refresh of \`config/api-tier-models.json\` (\`tier_models.opencode_go\`) from \`https://models.dev/api.json\`."
fi