Skip to content

Commit 8aa1c23

Browse files
author
Gianni Stubbe
committed
fix: use OpenCode App for plan replies
1 parent 8e71c8f commit 8aa1c23

3 files changed

Lines changed: 9 additions & 13 deletions

File tree

.github/workflows/opencode.yml

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,7 @@ jobs:
7171
environment: opencode-plan
7272
permissions:
7373
contents: read
74-
issues: write
75-
pull-requests: write
74+
id-token: write
7675
steps:
7776
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4
7877
with:
@@ -103,8 +102,6 @@ jobs:
103102
run: node .github/scripts/opencode-auth.mjs
104103
- name: Run read-only OpenCode plan
105104
env:
106-
GITHUB_TOKEN: ${{ github.token }}
107-
USE_GITHUB_TOKEN: 'true'
108105
MODEL: ${{ needs.authorize.outputs.model }}
109106
OPENCODE_CONFIG_CONTENT: >-
110107
{"share":"disabled","default_agent":"github-plan","small_model":"openai/gpt-5.6-luna","enabled_providers":["openai"],"provider":{"openai":{"whitelist":["gpt-5.6-sol","gpt-5.6-terra","gpt-5.6-luna"]}},"formatter":false,"lsp":false}
@@ -130,10 +127,6 @@ jobs:
130127
with:
131128
persist-credentials: false
132129
ref: ${{ github.event.repository.default_branch }}
133-
- name: Configure OpenCode commit identity
134-
run: |
135-
git config --local user.name 'github-actions[bot]'
136-
git config --local user.email '41898282+github-actions[bot]@users.noreply.github.com'
137130
- name: Install pinned OpenCode
138131
shell: bash
139132
run: |

.github/workflows/workflow-lint.yml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,15 +55,18 @@ jobs:
5555
assert.equal(config.agent["github-build"].permission.edit["*"], "allow")
5656
assert.equal(config.agent["github-build"].permission.edit[".github/**"], "deny")
5757
NODE
58-
- name: Verify plan token separation
58+
- name: Verify native OpenCode App identity
5959
shell: bash
6060
run: |
6161
set -euo pipefail
6262
plan_job="$(awk '/^ plan:/{inside=1} /^ build:/{inside=0} inside' .github/workflows/opencode.yml)"
63-
if grep -q 'id-token: write' <<<"$plan_job"; then
63+
grep -q 'id-token: write' <<<"$plan_job"
64+
if grep -qE 'GITHUB_TOKEN:|USE_GITHUB_TOKEN' <<<"$plan_job"; then
65+
exit 1
66+
fi
67+
if grep -qE 'Configure OpenCode commit identity|github-actions\[bot\]' .github/workflows/opencode.yml; then
6468
exit 1
6569
fi
66-
grep -q "USE_GITHUB_TOKEN: 'true'" .github/workflows/opencode.yml
6770
grep -q 'Reauthorize commenter after approval' .github/workflows/opencode.yml
6871
- name: Validate GitHub Actions workflows
6972
uses: docker://rhysd/actionlint@sha256:ef8299f97635c4c30e2298f48f30763ab782a4ad2c95b744649439a039421e36

docs/opencode-github.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ OpenCode responds to explicit commands in GitHub issue comments, pull request co
66

77
- Only the repository owner can invoke unapproved plan runs. Build requests require repository write/admin permission and the build-environment approval.
88
- Commands must start at the first character of a comment and use an allowlisted mode and model. Requests are limited to 8,000 characters; CRLF is normalized, and unsupported control characters are rejected.
9-
- Plan runs use the scoped `GITHUB_TOKEN` with read-only contents permission plus issue and pull-request comment/reaction write access. Build runs alone exchange OIDC for the OpenCode App token.
9+
- Both plan and build runs exchange GitHub OIDC for the installed OpenCode App token, so visible reactions, comments, branches, commits, and pull requests are authored by `opencode-agent[bot]`. The authorization and post-approval verification steps alone use scoped `GITHUB_TOKEN` credentials for invisible read-only checks.
1010
- Build runs require approval through the `opencode-build` environment. Fork PRs, non-open PRs, and PRs whose head is the default branch are rejected.
1111
- The build agent statically denies edits. A trusted startup plugin enables edits only for ordinary repository files and retains canonical and symlink path checks. If the plugin or config hook fails, editing stays denied.
1212
- The build agent has no shell, network, subagent, external-directory, or merge access. It cannot edit `.github/`, `.opencode/`, `.git/`, `opencode.json`, `AGENTS.md`, `vault_pass.sh`, `.env`, or `.env.*` files.
@@ -34,7 +34,7 @@ Create two GitHub environments:
3434
- `opencode-plan` has no required reviewer and contains only its copy of the four OAuth component secrets.
3535
- `opencode-build` has a required reviewer, prevents self-review, disables administrator bypass, and contains a separate copy of the four OAuth component secrets.
3636

37-
The installed OpenCode GitHub App must be installed only for this repository, have the minimum contents, issues, and pull-request permissions needed to create branches, comments, and pull requests, and have no branch/ruleset bypass. Build mode uses the App through OIDC so App-created changes trigger normal pull-request validation workflows; plan mode instead uses its scoped `GITHUB_TOKEN`.
37+
The installed OpenCode GitHub App must be installed only for this repository and have no branch/ruleset bypass. Both modes use the App through OIDC so App-created changes trigger normal pull-request validation workflows. The official App's installation token has App-defined permissions that cannot be reduced by per-job GitHub Actions permissions; owner-only plans remain read-only through the pinned OpenCode binary and the `github-plan` tool policy.
3838

3939
Create a ruleset or branch protection rule for `main` with:
4040

0 commit comments

Comments
 (0)