1010 required : false
1111
1212permissions :
13- contents : write
14- pull-requests : write
13+ contents : read
1514
1615jobs :
17- sync :
16+ generate :
17+ # Runs third-party npm code, so it has a read-only token and no stored credentials.
1818 runs-on : ubuntu-latest
19+ outputs :
20+ version : ${{ steps.version.outputs.version }}
1921 steps :
2022 - uses : actions/checkout@v5
23+ with :
24+ persist-credentials : false
2125 - uses : astral-sh/setup-uv@v6
2226 - uses : oven-sh/setup-bun@v2
2327 - name : Resolve version
2428 id : version
29+ env :
30+ REQUESTED : ${{ inputs.version }}
2531 run : |
26- version="${{ inputs.version } }"
27- if [ -z "$version" ] ; then version=$(npm view @opencode/protocol version) ; fi
32+ version="${REQUESTED:-$(npm view @opencode/protocol version) }"
33+ if ! printf '%s' "$version" | grep -Eq '^[0-9]+\.[0-9]+\.[0-9]+$' ; then echo "Invalid version: $ version"; exit 1 ; fi
2834 effect=$(npm view "@opencode/protocol@$version" dependencies.effect)
2935 echo "version=$version" >> "$GITHUB_OUTPUT"
3036 echo "effect=$effect" >> "$GITHUB_OUTPUT"
@@ -33,20 +39,42 @@ jobs:
3339 run : |
3440 bun add --exact --ignore-scripts "@opencode/protocol@${{ steps.version.outputs.version }}" "effect@${{ steps.version.outputs.effect }}"
3541 bun run extract.ts
36- - name : Regenerate client
42+ - name : Regenerate and verify
3743 run : |
3844 uv sync --locked
3945 uv run python -m codegen
4046 uv run ruff check .
4147 uv run pyright
4248 uv run pytest -m "not live"
49+ - run : git diff > sync.patch
50+ - uses : actions/upload-artifact@v4
51+ with :
52+ name : sync-patch
53+ path : sync.patch
54+
55+ pull-request :
56+ # Has write access but only applies the reviewed patch; it runs no project or npm code.
57+ needs : generate
58+ runs-on : ubuntu-latest
59+ permissions :
60+ contents : write
61+ pull-requests : write
62+ steps :
63+ - uses : actions/checkout@v5
64+ - uses : actions/download-artifact@v4
65+ with :
66+ name : sync-patch
67+ - name : Apply patch
68+ run : |
69+ if [ -s sync.patch ]; then git apply sync.patch; fi
70+ rm sync.patch
4371 - uses : peter-evans/create-pull-request@v7
4472 with :
45- branch : sync/opencode-${{ steps.version .outputs.version }}
46- title : " Sync with OpenCode ${{ steps.version .outputs.version }}"
47- commit-message : " Sync with OpenCode ${{ steps.version .outputs.version }}"
73+ branch : sync/opencode-${{ needs.generate .outputs.version }}
74+ title : " Sync with OpenCode ${{ needs.generate .outputs.version }}"
75+ commit-message : " Sync with OpenCode ${{ needs.generate .outputs.version }}"
4876 body : |
49- Regenerated from `@opencode/protocol@${{ steps.version .outputs.version }}`.
77+ Regenerated from `@opencode/protocol@${{ needs.generate .outputs.version }}`.
5078
5179 Review `api.md` for added, removed or changed operations before merging.
5280 delete-branch : true
0 commit comments