diff --git a/.github/workflows/opencode.yml b/.github/workflows/opencode.yml index 3b20e7b..c682552 100644 --- a/.github/workflows/opencode.yml +++ b/.github/workflows/opencode.yml @@ -5,8 +5,6 @@ on: types: [created] pull_request_review_comment: types: [created] - pull_request: - types: [opened, synchronize, reopened, ready_for_review] issues: types: [opened] diff --git a/.github/workflows/pr-reviewer.yml b/.github/workflows/pr-reviewer.yml new file mode 100644 index 0000000..187ea33 --- /dev/null +++ b/.github/workflows/pr-reviewer.yml @@ -0,0 +1,46 @@ +name: opencode-review + +on: + pull_request: + types: [opened, synchronize, reopened, ready_for_review] + +permissions: + contents: read + +jobs: + review: + # 跳过 fork 来的 PR:GitHub 不会把 secrets 传给 fork PR 触发的工作流, + # 跑了也必然失败,所以直接跳过避免噪音(平台限制,非配置问题)。 + if: github.event.pull_request.head.repo.fork == false + runs-on: ubuntu-latest + steps: + - name: Generate bot token + id: token + uses: actions/create-github-app-token@v1 + with: + app-id: ${{ secrets.APP_ID }} + private-key: ${{ secrets.APP_PRIVATE_KEY }} + owner: ${{ github.repository_owner }} + + - name: Checkout + uses: actions/checkout@v6 + with: + persist-credentials: false + token: ${{ steps.token.outputs.token }} + + - name: Configure git identity + run: | + git config --global user.name "takanashi-hoshino-agent[bot]" + git config --global user.email "takanashi-hoshino-agent[bot]@users.noreply.github.com" + + - name: Run opencode review + uses: anomalyco/opencode/github@latest + env: + OPENCODE_API_KEY: ${{ secrets.OPENCODE_API_KEY }} + # 用自定义 GitHub App 生成的 bot token,跟原 opencode.yml 一致, + # 评论 PR / 提交都走 takanashi-hoshino-agent[bot] 的身份。 + GITHUB_TOKEN: ${{ steps.token.outputs.token }} + with: + model: opencode/deepseek-v4-flash-free + use_github_token: true + prompt: ${{ secrets.OPENCODE_PROMPT }}