1.5 KiB
1.5 KiB
OpenCode PR Review Workflow
Use this pattern when adding a repo-scoped OpenCode reviewer to Gitea Actions.
Core behavior:
- Trigger only from PR comments containing
/reviewand optionalworkflow_dispatch. - Do not auto-review on PR open or synchronize for the first version.
- Run OpenCode read-only.
- Post or update one aggregate PR comment using a stable marker such as
<!-- opencode-review -->. - Checkout the PR head tree shallowly for repository context.
- Do not expose Gitea API tokens to OpenCode.
Required secrets:
REVIEW_BOT_TOKEN: Gitea token withread:repository,read:issue, andwrite:issue.OPENCODE_GO_TOKEN: OpenCode Go API token.
Preparation step should:
- Read
$GITHUB_EVENT_PATHwithjq. - Skip unless action is
created, issue is a PR, and comment contains/review. - Fetch PR metadata from
GET /repos/{owner}/{repo}/pulls/{number}. - Fetch diff from
GET /repos/{owner}/{repo}/pulls/{number}.diff. - Export
PR_NUMBER,REPO,BASE_BRANCH,HEAD_BRANCH, andHEAD_SHA.
Checkout pattern:
- uses: actions/checkout@v4
with:
ref: ${{ env.HEAD_SHA }}
fetch-depth: 1
persist-credentials: false
Avoid fetch-depth: 0 unless full history is required.
Before invoking OpenCode, generate auth from OPENCODE_GO_TOKEN, disable mutation tools, and unset repository tokens from the environment.
Gitea Actions logs can be awkward before Gitea 1.26; if tea actions runs logs is unavailable or incomplete, inspect run/task state through the Gitea API.