PR agent
This commit is contained in:
parent
63274e97a4
commit
8907793275
1 changed files with 31 additions and 49 deletions
76
.github/workflows/opencode.yml
vendored
76
.github/workflows/opencode.yml
vendored
|
|
@ -14,8 +14,8 @@ on:
|
||||||
types: [submitted]
|
types: [submitted]
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
# Manual opencode execution via comments
|
# Handle opencode execution via comments
|
||||||
opencode-manual:
|
opencode:
|
||||||
if: |
|
if: |
|
||||||
github.event_name == 'issue_comment' && (
|
github.event_name == 'issue_comment' && (
|
||||||
contains(github.event.comment.body, ' /oc') ||
|
contains(github.event.comment.body, ' /oc') ||
|
||||||
|
|
@ -42,72 +42,54 @@ jobs:
|
||||||
with:
|
with:
|
||||||
model: anthropic/claude-sonnet-4-20250514
|
model: anthropic/claude-sonnet-4-20250514
|
||||||
|
|
||||||
# Automatic PR review when PR is opened or updated
|
# Automatically create review comment when PR is opened
|
||||||
opencode-pr-review:
|
auto-review-trigger:
|
||||||
if: |
|
if: |
|
||||||
github.event_name == 'pull_request' && (
|
github.event_name == 'pull_request' && (
|
||||||
github.event.action == 'opened' ||
|
github.event.action == 'opened' ||
|
||||||
github.event.action == 'synchronize' ||
|
|
||||||
github.event.action == 'ready_for_review'
|
github.event.action == 'ready_for_review'
|
||||||
) && !github.event.pull_request.draft
|
) && !github.event.pull_request.draft
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
permissions:
|
permissions:
|
||||||
contents: write
|
|
||||||
pull-requests: write
|
pull-requests: write
|
||||||
issues: write
|
|
||||||
id-token: write
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout repository
|
- name: Create auto-review comment
|
||||||
uses: actions/checkout@v4
|
uses: actions/github-script@v7
|
||||||
with:
|
with:
|
||||||
fetch-depth: 0
|
script: |
|
||||||
|
const { owner, repo } = context.repo;
|
||||||
|
const issue_number = context.payload.pull_request.number;
|
||||||
|
|
||||||
- name: Checkout PR branch
|
await github.rest.issues.createComment({
|
||||||
run: |
|
owner,
|
||||||
gh pr checkout ${{ github.event.number }}
|
repo,
|
||||||
env:
|
issue_number,
|
||||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
body: '/opencode Please review this PR. Check for code quality, potential bugs, security issues, and adherence to best practices. Provide constructive feedback and suggestions for improvement.'
|
||||||
|
});
|
||||||
|
|
||||||
- name: Auto-review PR
|
# Automatically trigger re-review when requested
|
||||||
uses: sst/opencode/github@latest
|
re-review-trigger:
|
||||||
env:
|
|
||||||
ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
|
|
||||||
OPENCODE_COMMENT: "/opencode @codebase-agent Please review this PR. Check for code quality, potential bugs, security issues, and adherence to best practices. Provide constructive feedback and suggestions for improvement."
|
|
||||||
with:
|
|
||||||
model: anthropic/claude-sonnet-4-20250514
|
|
||||||
|
|
||||||
# Re-review when specifically requested via PR review
|
|
||||||
opencode-re-review:
|
|
||||||
if: |
|
if: |
|
||||||
github.event_name == 'pull_request_review' &&
|
github.event_name == 'pull_request_review' &&
|
||||||
github.event.review.state == 'commented' && (
|
github.event.review.state == 'commented' && (
|
||||||
contains(github.event.review.body, 're-review') ||
|
contains(github.event.review.body, 're-review') ||
|
||||||
contains(github.event.review.body, 'check again') ||
|
contains(github.event.review.body, 'check again') ||
|
||||||
contains(github.event.review.body, '/oc') ||
|
contains(github.event.review.body, 'review again')
|
||||||
contains(github.event.review.body, '/opencode')
|
|
||||||
)
|
)
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
permissions:
|
permissions:
|
||||||
contents: write
|
|
||||||
pull-requests: write
|
pull-requests: write
|
||||||
issues: write
|
|
||||||
id-token: write
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout repository
|
- name: Create re-review comment
|
||||||
uses: actions/checkout@v4
|
uses: actions/github-script@v7
|
||||||
with:
|
with:
|
||||||
fetch-depth: 0
|
script: |
|
||||||
|
const { owner, repo } = context.repo;
|
||||||
|
const issue_number = context.payload.pull_request.number;
|
||||||
|
|
||||||
- name: Checkout PR branch
|
await github.rest.issues.createComment({
|
||||||
run: |
|
owner,
|
||||||
gh pr checkout ${{ github.event.pull_request.number }}
|
repo,
|
||||||
env:
|
issue_number,
|
||||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
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.'
|
||||||
|
});
|
||||||
- name: Re-review PR
|
|
||||||
uses: sst/opencode/github@latest
|
|
||||||
env:
|
|
||||||
ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
|
|
||||||
OPENCODE_COMMENT: "/opencode Please re-review this PR based on the latest changes. Focus on the recent updates and provide feedback on improvements made."
|
|
||||||
with:
|
|
||||||
model: anthropic/claude-sonnet-4-20250514
|
|
||||||
Loading…
Reference in a new issue