This commit is contained in:
darrenhinde 2025-08-25 23:51:40 +01:00
parent b4e642a839
commit 2339935930

View file

@ -1,31 +1,25 @@
name: opencode
on:
# Trigger on issue/PR comments for manual requests
issue_comment:
types: [created]
# Trigger on PR events for automatic reviews
pull_request:
types: [opened, synchronize, ready_for_review]
types: [opened, ready_for_review]
# Trigger on PR review requests for re-reviews
pull_request_review:
types: [submitted]
env:
REVIEW_PROMPT: "Please review this PR for code quality, bugs, and best practices."
jobs:
# Handle opencode execution via comments
opencode:
if: |
github.event_name == 'issue_comment' && (
contains(github.event.comment.body, ' /oc') ||
contains(github.event.comment.body, '/oc ') ||
startsWith(github.event.comment.body, '/oc') ||
contains(github.event.comment.body, ' /opencode') ||
contains(github.event.comment.body, '/opencode ') ||
startsWith(github.event.comment.body, '/opencode')
)
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
issues: write
id-token: write
@ -33,63 +27,31 @@ jobs:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
fetch-depth: 1
- name: Run opencode
uses: sst/opencode/github@latest
uses: sst/opencode/github@v0.5.27
env:
ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
with:
model: anthropic/claude-sonnet-4-20250514
model: claude-3-5-sonnet-20241022
# Automatically create review comment when PR is opened
auto-review-trigger:
auto-review:
if: |
github.event_name == 'pull_request' && (
github.event.action == 'opened' ||
github.event.action == 'ready_for_review'
) && !github.event.pull_request.draft
github.event_name == 'pull_request' &&
(github.event.action == 'opened' || github.event.action == 'ready_for_review') &&
!github.event.pull_request.draft
runs-on: ubuntu-latest
permissions:
pull-requests: write
steps:
- name: Create auto-review comment
- name: Request review
uses: actions/github-script@v7
with:
script: |
const { owner, repo } = context.repo;
const issue_number = context.payload.pull_request.number;
await github.rest.issues.createComment({
owner,
repo,
issue_number,
body: '/opencode @review Please review this PR. Check for code quality, potential bugs, security issues, and adherence to best practices. Provide constructive feedback and suggestions for improvement.'
});
# Automatically trigger re-review when requested
re-review-trigger:
if: |
github.event_name == 'pull_request_review' &&
github.event.review.state == 'commented' && (
contains(github.event.review.body, 're-review') ||
contains(github.event.review.body, 'check again') ||
contains(github.event.review.body, 'review again')
)
runs-on: ubuntu-latest
permissions:
pull-requests: write
steps:
- name: Create re-review comment
uses: actions/github-script@v7
with:
script: |
const { owner, repo } = context.repo;
const issue_number = context.payload.pull_request.number;
await github.rest.issues.createComment({
owner,
repo,
issue_number,
body: '/opencode @review Please re-review this PR based on the latest changes. Focus on the recent updates and provide feedback on improvements made since the last review.'
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.payload.pull_request.number,
body: `/oc ${process.env.REVIEW_PROMPT}`
});