opencode.yml 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. name: opencode
  2. on:
  3. issue_comment:
  4. types: [created]
  5. pull_request:
  6. types: [opened, ready_for_review]
  7. env:
  8. REVIEW_PROMPT: "Please review this PR for code quality, bugs, and best practices."
  9. jobs:
  10. opencode:
  11. if: |
  12. github.event_name == 'issue_comment' && (
  13. contains(github.event.comment.body, '/oc ') ||
  14. startsWith(github.event.comment.body, '/oc') ||
  15. contains(github.event.comment.body, '/opencode ') ||
  16. startsWith(github.event.comment.body, '/opencode')
  17. )
  18. runs-on: ubuntu-latest
  19. permissions:
  20. pull-requests: write
  21. issues: write
  22. id-token: write
  23. steps:
  24. - name: Checkout repository
  25. uses: actions/checkout@v4
  26. with:
  27. fetch-depth: 1
  28. - name: Run opencode
  29. uses: sst/opencode/github@v0.5.27
  30. env:
  31. ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
  32. with:
  33. model: claude-3-5-sonnet-20241022
  34. auto-review:
  35. if: |
  36. github.event_name == 'pull_request' &&
  37. (github.event.action == 'opened' || github.event.action == 'ready_for_review') &&
  38. !github.event.pull_request.draft
  39. runs-on: ubuntu-latest
  40. permissions:
  41. pull-requests: write
  42. steps:
  43. - name: Request review
  44. uses: actions/github-script@v7
  45. with:
  46. script: |
  47. await github.rest.issues.createComment({
  48. owner: context.repo.owner,
  49. repo: context.repo.repo,
  50. issue_number: context.payload.pull_request.number,
  51. body: `/oc ${process.env.REVIEW_PROMPT}`
  52. });