-
Notifications
You must be signed in to change notification settings - Fork 14
68 lines (61 loc) · 2.31 KB
/
opencode.yml
File metadata and controls
68 lines (61 loc) · 2.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
name: opencode
on:
issue_comment:
types: [created]
pull_request_review_comment:
types: [created]
issues:
types: [opened, assigned]
pull_request_review:
types: [submitted]
jobs:
opencode:
if: |
(github.event_name == 'issue_comment' && contains(github.event.comment.body, '/opencode:')) ||
(github.event_name == 'pull_request_review_comment' && contains(github.event.comment.body, '/opencode:')) ||
(github.event_name == 'pull_request_review' && contains(github.event.review.body, '/opencode:')) ||
(github.event_name == 'issues' && contains(github.event.issue.body, '/opencode:'))
runs-on: ubuntu-latest
permissions:
id-token: write
contents: write
pull-requests: write
issues: write
steps:
- name: Checkout repository
uses: actions/checkout@v6
with:
fetch-depth: 1
persist-credentials: false
- name: Extract agent name
id: agent
env:
COMMENT_BODY: ${{ github.event.comment.body || github.event.review.body || github.event.issue.body }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
AGENT=$(echo "$COMMENT_BODY" | grep -oP '/opencode:\K[A-Za-z]+' | head -1)
if [[ ! "$AGENT" =~ ^(Build|Plan)$ ]]; then
ERROR_MSG="Error: Invalid agent '$AGENT'. Must be Build or Plan"
echo "$ERROR_MSG"
# Post comment with error
if [ "${{ github.event_name }}" = "issues" ]; then
NUMBER=${{ github.event.issue.number }}
else
NUMBER=${{ github.event.issue.number || github.event.pull_request.number }}
fi
curl -s -X POST \
-H "Authorization: token $GITHUB_TOKEN" \
-H "Accept: application/vnd.github.v3+json" \
"https://api.github.com/repos/${{ github.repository }}/issues/$NUMBER/comments" \
-d "{\"body\": \"❌ $ERROR_MSG\"}"
exit 1
fi
echo "agent=$AGENT" >> $GITHUB_OUTPUT
- name: Run opencode
uses: anomalyco/opencode/github@latest
env:
OPENCODE_API_KEY: ${{ secrets.OPENCODE_API_KEY }}
OPENCODE_PERMISSION: '{"bash": "deny"}'
with:
model: opencode-go/kimi-k2.5
agent: ${{ steps.agent.outputs.agent }}