Repository navigation
86 lines (75 loc) · 3.51 KB
/
Copy pathopencode-review.yml
File metadata and controls
86 lines (75 loc) · 3.51 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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
name: OpenCode PR Review
on:
pull_request:
branches: master
types: [opened, synchronize, reopened, ready_for_review]
concurrency:
group: opencode-review-${{ github.event.pull_request.number }}
cancel-in-progress: true
jobs:
review:
name: Review pull request
if: ${{ !github.event.pull_request.draft }}
runs-on: ubuntu-latest
timeout-minutes: 15
permissions:
contents: read
pull-requests: write
# OpenCode posts its PR summary/session link via issues.createComment.
issues: write
steps:
- name: Check trigger user permissions
id: trigger-permission
env:
GH_TOKEN: ${{ github.token }}
TRIGGER_USER: ${{ github.actor }}
run: |
encoded_user=$(jq -nr --arg value "$TRIGGER_USER" '$value|@uri')
permission_error=$(mktemp)
if ! permission=$(gh api "repos/${GITHUB_REPOSITORY}/collaborators/${encoded_user}/permission" --jq '.permission' 2>"$permission_error"); then
echo "OpenCode permission lookup failed; treating ${TRIGGER_USER} as having no repository permission."
sed 's/^/gh api: /' "$permission_error"
permission="none"
fi
rm -f "$permission_error"
permission=${permission:-none}
echo "permission=${permission}" >> "$GITHUB_OUTPUT"
if [[ "$permission" == "admin" || "$permission" == "write" ]]; then
echo "can_review=true" >> "$GITHUB_OUTPUT"
else
echo "can_review=false" >> "$GITHUB_OUTPUT"
echo "Skipping OpenCode review because ${TRIGGER_USER} has ${permission} repository permission, not write/admin."
fi
- name: Checkout repository
if: ${{ steps['trigger-permission'].outputs.can_review == 'true' }}
uses: actions/checkout@v7
with:
persist-credentials: false
- name: Run OpenCode review
if: ${{ steps['trigger-permission'].outputs.can_review == 'true' }}
uses: anomalyco/opencode/github@d4ad650f738aaa986cee5879c581bd4834277577
env:
GITHUB_TOKEN: ${{ github.token }}
OPENCODE_API_KEY: ${{ secrets.OPENCODE_API_KEY }}
with:
model: opencode-go/deepseek-v4.1-flash
share: false
use_github_token: true
prompt: |
Review this pull request as a senior maintainer.
During analysis, be adversarial: try to find ways this change could break correctness,
security, permissions, reliability, CI behavior, performance, or create concrete long-term maintenance risk.
Be conservative in what you report. Before reporting a finding, double-check it:
- it is caused by this PR
- it is reachable or materially risky
- it would be worth requesting changes for
- it is not already covered by existing review comments, if available
- it is not speculative, low-impact, duplicative, or mainly subjective
Only report high-confidence findings. Prefer no findings over weak findings.
Report at most 5 findings, ordered by severity.
For each finding, include:
- the concrete risk
- the relevant changed line or behavior
- the smallest practical fix
Do not comment on style, formatting, naming, or preferences unless they create a concrete bug, security issue, or clearly explainable maintenance risk.
Do not modify files, commit changes, or push to the pull request branch.