opencode.yml 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. name: opencode
  2. on:
  3. # Trigger on issue/PR comments for manual requests
  4. issue_comment:
  5. types: [created]
  6. # Trigger on PR events for automatic reviews
  7. pull_request:
  8. types: [opened, synchronize, ready_for_review]
  9. # Trigger on PR review requests for re-reviews
  10. pull_request_review:
  11. types: [submitted]
  12. jobs:
  13. # Manual opencode execution via comments
  14. opencode-manual:
  15. if: |
  16. github.event_name == 'issue_comment' && (
  17. contains(github.event.comment.body, ' /oc') ||
  18. startsWith(github.event.comment.body, '/oc') ||
  19. contains(github.event.comment.body, ' /opencode') ||
  20. startsWith(github.event.comment.body, '/opencode')
  21. )
  22. runs-on: ubuntu-latest
  23. permissions:
  24. contents: write
  25. pull-requests: write
  26. issues: write
  27. id-token: write
  28. steps:
  29. - name: Checkout repository
  30. uses: actions/checkout@v4
  31. with:
  32. fetch-depth: 0
  33. - name: Run opencode
  34. uses: sst/opencode/github@latest
  35. env:
  36. ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
  37. with:
  38. model: anthropic/claude-sonnet-4-20250514
  39. # Automatic PR review when PR is opened or updated
  40. opencode-pr-review:
  41. if: |
  42. github.event_name == 'pull_request' && (
  43. github.event.action == 'opened' ||
  44. github.event.action == 'synchronize' ||
  45. github.event.action == 'ready_for_review'
  46. ) && !github.event.pull_request.draft
  47. runs-on: ubuntu-latest
  48. permissions:
  49. contents: write
  50. pull-requests: write
  51. issues: write
  52. id-token: write
  53. steps:
  54. - name: Checkout repository
  55. uses: actions/checkout@v4
  56. with:
  57. fetch-depth: 0
  58. - name: Checkout PR branch
  59. run: |
  60. gh pr checkout ${{ github.event.number }}
  61. env:
  62. GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  63. - name: Auto-review PR
  64. uses: sst/opencode/github@latest
  65. env:
  66. ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
  67. OPENCODE_COMMENT: "/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."
  68. with:
  69. model: anthropic/claude-sonnet-4-20250514
  70. # Re-review when specifically requested via PR review
  71. opencode-re-review:
  72. if: |
  73. github.event_name == 'pull_request_review' &&
  74. github.event.review.state == 'commented' && (
  75. contains(github.event.review.body, 're-review') ||
  76. contains(github.event.review.body, 'check again') ||
  77. contains(github.event.review.body, '/oc') ||
  78. contains(github.event.review.body, '/opencode')
  79. )
  80. runs-on: ubuntu-latest
  81. permissions:
  82. contents: write
  83. pull-requests: write
  84. issues: write
  85. id-token: write
  86. steps:
  87. - name: Checkout repository
  88. uses: actions/checkout@v4
  89. with:
  90. fetch-depth: 0
  91. - name: Checkout PR branch
  92. run: |
  93. gh pr checkout ${{ github.event.pull_request.number }}
  94. env:
  95. GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  96. - name: Re-review PR
  97. uses: sst/opencode/github@latest
  98. env:
  99. ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
  100. OPENCODE_COMMENT: "/opencode Please re-review this PR based on the latest changes. Focus on the recent updates and provide feedback on improvements made."
  101. with:
  102. model: anthropic/claude-sonnet-4-20250514