1111 types : [submitted]
1212
1313jobs :
14- opencode-read :
15- name : OpenCode (Read-only)
14+ opencode :
1615 if : |
17- (github.event_name == 'issue_comment' && contains(github.event.comment.body, '/opencode:read ')) ||
18- (github.event_name == 'pull_request_review_comment' && contains(github.event.comment.body, '/opencode:read ')) ||
19- (github.event_name == 'pull_request_review' && contains(github.event.review.body, '/opencode:read ')) ||
20- (github.event_name == 'issues' && contains(github.event.issue.body, '/opencode:read '))
16+ (github.event_name == 'issue_comment' && contains(github.event.comment.body, '/opencode:')) ||
17+ (github.event_name == 'pull_request_review_comment' && contains(github.event.comment.body, '/opencode:')) ||
18+ (github.event_name == 'pull_request_review' && contains(github.event.review.body, '/opencode:')) ||
19+ (github.event_name == 'issues' && contains(github.event.issue.body, '/opencode:'))
2120 runs-on : ubuntu-latest
2221 permissions :
2322 id-token : write
24- contents : read
23+ contents : write
2524 pull-requests : write
2625 issues : write
2726 steps :
@@ -31,36 +30,23 @@ jobs:
3130 fetch-depth : 1
3231 persist-credentials : false
3332
34- - name : Run opencode
35- uses : anomalyco/opencode/github@latest
33+ - name : Extract agent name
34+ id : agent
3635 env :
37- OPENCODE_API_KEY : ${{ secrets.OPENCODE_API_KEY }}
38- with :
39- model : opencode-go/glm-5
40-
41- opencode-write :
42- name : OpenCode (Write access)
43- if : |
44- (github.event_name == 'issue_comment' && contains(github.event.comment.body, '/opencode:write')) ||
45- (github.event_name == 'pull_request_review_comment' && contains(github.event.comment.body, '/opencode:write')) ||
46- (github.event_name == 'pull_request_review' && contains(github.event.review.body, '/opencode:write')) ||
47- (github.event_name == 'issues' && contains(github.event.issue.body, '/opencode:write'))
48- runs-on : ubuntu-latest
49- permissions :
50- id-token : write
51- contents : write
52- pull-requests : write
53- issues : write
54- steps :
55- - name : Checkout repository
56- uses : actions/checkout@v6
57- with :
58- fetch-depth : 1
59- persist-credentials : false
36+ COMMENT_BODY : ${{ github.event.comment.body || github.event.review.body || github.event.issue.body }}
37+ run : |
38+ AGENT=$(echo "$COMMENT_BODY" | grep -oP '/opencode:\K[A-Za-z]+' | head -1)
39+ if [ -z "$AGENT" ]; then
40+ echo "Error: No agent specified after /opencode:"
41+ exit 1
42+ fi
43+ echo "agent=$AGENT" >> $GITHUB_OUTPUT
6044
6145 - name : Run opencode
6246 uses : anomalyco/opencode/github@latest
6347 env :
6448 OPENCODE_API_KEY : ${{ secrets.OPENCODE_API_KEY }}
49+ OPENCODE_PERMISSION : ' {"bash": "deny"}'
6550 with :
6651 model : opencode-go/glm-5
52+ agent : ${{ steps.agent.outputs.agent }}
0 commit comments