Skip to content

Commit 22f62e9

Browse files
committed
ci: add opencode review workflow for PR comments
1 parent db4dab3 commit 22f62e9

1 file changed

Lines changed: 81 additions & 0 deletions

File tree

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
name: opencode-review
2+
3+
on:
4+
# issue_comment covers both issues and PR comments
5+
issue_comment:
6+
types: [created]
7+
pull_request_review_comment:
8+
types: [created]
9+
10+
jobs:
11+
review:
12+
# Only trigger in PRs (not issues), and require @opencode or /opencode trigger
13+
if: |
14+
(
15+
github.event_name == 'issue_comment' &&
16+
github.event.issue.pull_request &&
17+
(
18+
contains(github.event.comment.body, '@opencode') ||
19+
contains(github.event.comment.body, '/opencode')
20+
)
21+
) ||
22+
(
23+
github.event_name == 'pull_request_review_comment' &&
24+
(
25+
contains(github.event.comment.body, '@opencode') ||
26+
contains(github.event.comment.body, '/opencode')
27+
)
28+
)
29+
runs-on: ubuntu-latest
30+
permissions:
31+
contents: read # Change to 'write' to allow OpenCode to push commits
32+
pull-requests: write # Required to post comments (kept as write for responses)
33+
issues: read # Change to 'write' if you enable issue workflows later
34+
actions: read # Required to read CI results on PRs
35+
id-token: write # Required for OIDC token generation (OpenCode GitHub App)
36+
steps:
37+
- uses: actions/checkout@v6
38+
with:
39+
persist-credentials: false
40+
- uses: anomalyco/opencode/github@latest
41+
env:
42+
# ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
43+
ZHIPU_API_KEY: ${{ secrets.ZHIPU_API_KEY }}
44+
ZHIPU_BASE_URL: ${{ secrets.ZHIPU_BASE_URL }}
45+
# with:
46+
# # model: anthropic/claude-sonnet-4-20250514
47+
# model: zai-coding-plan/glm-4.7
48+
# use_github_token: true
49+
# prompt: |
50+
# Review this pull request:
51+
# - Check for code quality issues
52+
# - Look for potential bugs
53+
# - Suggest improvements
54+
with:
55+
model: ${{ secrets.OPENCODE_PR_REVIEW_MODEL }}
56+
share: false
57+
agent: plan
58+
prompt: |
59+
IMPORTANT CONSTRAINTS: You are running in READ-ONLY mode for code review purposes and final output must be in Chinese.
60+
61+
You CANNOT:
62+
- Edit files, write files, or create new files
63+
- Run bash/shell commands
64+
- Execute git operations (commit, push, merge, etc.)
65+
- Merge PRs, create branches, or push commits
66+
- Search the web or fetch external URLs
67+
68+
You CAN:
69+
- Read files to understand code
70+
- Search code using Grep
71+
- List directories
72+
- Use Glob to find files
73+
- Answer questions about the codebase
74+
- Review PRs and provide detailed feedback
75+
- Explain code, suggest improvements, and clarify reviewer comments
76+
77+
If a user requests a restricted action (e.g., "merge this PR", "apply these changes", "edit this file", "run tests"), politely decline and explain:
78+
1. What you cannot do
79+
2. What you CAN do instead (e.g., suggest exact commands the user can copy, provide code snippets to paste, explain the changes needed)
80+
81+
Focus on being a helpful code reviewer: explain code, identify potential issues, suggest improvements, and help the user understand feedback from other reviewers.

0 commit comments

Comments
 (0)