From cfdc55fbc582de145e111c7350996b554cf44851 Mon Sep 17 00:00:00 2001 From: OtonariShunji Date: Wed, 7 Oct 2026 12:11:28 +0900 Subject: [PATCH 01/10] =?UTF-8?q?gemini=E3=81=AE=E3=83=AC=E3=83=93?= =?UTF-8?q?=E3=83=A5=E3=83=BC=E3=82=92=E8=BF=BD=E5=8A=A0=E3=81=97=E3=81=BE?= =?UTF-8?q?=E3=81=99=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/gemini-review.yml | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 .github/workflows/gemini-review.yml diff --git a/.github/workflows/gemini-review.yml b/.github/workflows/gemini-review.yml new file mode 100644 index 0000000..7b5fc11 --- /dev/null +++ b/.github/workflows/gemini-review.yml @@ -0,0 +1,26 @@ +name: Gemini CLI Agent +on: + pull_request: + types: [opened, synchronize, reopened] + issues: + types: [opened] + +jobs: + gemini: + runs-on: ubuntu-latest + permissions: + contents: read + pull-requests: write + issues: write + steps: + - uses: actions/checkout@v4 + - uses: google-github-actions/run-gemini-cli@v0 + with: + gemini_api_key: ${{ secrets.GEMINI_API_KEY }} + workflow: pr-review + prompt: | + あなたは極めて優秀なシニアエンジニアです。 + 提出されたコードの差分(Diff)を分析し、以下の観点からレビューしてコメントを日本語で残してください。 + 1. バグの引き金になりそうな潜在的な問題 + 2. パフォーマンスや計算効率の改善点 + 3. コードの可読性やメンテナンス性 From 2adcc044eddcdb7f2d18895f5167706ab91e0ee2 Mon Sep 17 00:00:00 2001 From: OtonariShunji Date: Wed, 7 Oct 2026 12:19:45 +0900 Subject: [PATCH 02/10] =?UTF-8?q?GEMINI=5FCLI=5FTRUST=5FWORKSPACE=E3=82=92?= =?UTF-8?q?=E8=BF=BD=E5=8A=A0=E3=81=97=E3=81=BE=E3=81=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/gemini-review.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/gemini-review.yml b/.github/workflows/gemini-review.yml index 7b5fc11..452179f 100644 --- a/.github/workflows/gemini-review.yml +++ b/.github/workflows/gemini-review.yml @@ -12,6 +12,8 @@ jobs: contents: read pull-requests: write issues: write + env: + GEMINI_CLI_TRUST_WORKSPACE: "true" steps: - uses: actions/checkout@v4 - uses: google-github-actions/run-gemini-cli@v0 From cdb3bd435310386c9d16abdd40738250adeae9bd Mon Sep 17 00:00:00 2001 From: OtonariShunji Date: Wed, 7 Oct 2026 12:26:52 +0900 Subject: [PATCH 03/10] =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E3=81=97=E3=81=BE?= =?UTF-8?q?=E3=81=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/gemini-review.yml | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/.github/workflows/gemini-review.yml b/.github/workflows/gemini-review.yml index 452179f..1cc8125 100644 --- a/.github/workflows/gemini-review.yml +++ b/.github/workflows/gemini-review.yml @@ -19,10 +19,5 @@ jobs: - uses: google-github-actions/run-gemini-cli@v0 with: gemini_api_key: ${{ secrets.GEMINI_API_KEY }} - workflow: pr-review - prompt: | - あなたは極めて優秀なシニアエンジニアです。 - 提出されたコードの差分(Diff)を分析し、以下の観点からレビューしてコメントを日本語で残してください。 - 1. バグの引き金になりそうな潜在的な問題 - 2. パフォーマンスや計算効率の改善点 - 3. コードの可読性やメンテナンス性 + workflow: auto + options: '--language ja --system-instruction "すべての回答、コメント、ラベル提案、レビューフィードバックは必ず日本語で行ってください。"' \ No newline at end of file From 618bc9671f9aa812fee802c57c89ee08e6508d31 Mon Sep 17 00:00:00 2001 From: OtonariShunji Date: Wed, 7 Oct 2026 13:39:03 +0900 Subject: [PATCH 04/10] =?UTF-8?q?gemini=E3=83=AC=E3=83=93=E3=83=A5?= =?UTF-8?q?=E3=83=BC=E3=81=AE=E3=83=AF=E3=83=BC=E3=82=AF=E3=83=95=E3=83=AD?= =?UTF-8?q?=E3=83=BC=E3=82=92=E6=9B=B4=E6=96=B0=E3=81=97=E3=80=81=E7=92=B0?= =?UTF-8?q?=E5=A2=83=E5=A4=89=E6=95=B0=E3=82=92=E5=89=8A=E9=99=A4=E3=81=97?= =?UTF-8?q?=E3=81=BE=E3=81=97=E3=81=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/gemini-review.yml | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/.github/workflows/gemini-review.yml b/.github/workflows/gemini-review.yml index 1cc8125..c69b037 100644 --- a/.github/workflows/gemini-review.yml +++ b/.github/workflows/gemini-review.yml @@ -12,12 +12,9 @@ jobs: contents: read pull-requests: write issues: write - env: - GEMINI_CLI_TRUST_WORKSPACE: "true" steps: - uses: actions/checkout@v4 - uses: google-github-actions/run-gemini-cli@v0 with: gemini_api_key: ${{ secrets.GEMINI_API_KEY }} - workflow: auto - options: '--language ja --system-instruction "すべての回答、コメント、ラベル提案、レビューフィードバックは必ず日本語で行ってください。"' \ No newline at end of file + workflow: pr-review # or issue-triage / on-demand \ No newline at end of file From a232e81eab4ff76c82e167ee044d30761a18232e Mon Sep 17 00:00:00 2001 From: OtonariShunji Date: Wed, 7 Oct 2026 13:40:25 +0900 Subject: [PATCH 05/10] =?UTF-8?q?GEMINI=5FCLI=5FTRUST=5FWORKSPACE=E7=92=B0?= =?UTF-8?q?=E5=A2=83=E5=A4=89=E6=95=B0=E3=82=92=E8=BF=BD=E5=8A=A0=E3=81=97?= =?UTF-8?q?=E3=81=BE=E3=81=97=E3=81=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/gemini-review.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/gemini-review.yml b/.github/workflows/gemini-review.yml index c69b037..5e77216 100644 --- a/.github/workflows/gemini-review.yml +++ b/.github/workflows/gemini-review.yml @@ -12,6 +12,8 @@ jobs: contents: read pull-requests: write issues: write + env: + GEMINI_CLI_TRUST_WORKSPACE: "true" steps: - uses: actions/checkout@v4 - uses: google-github-actions/run-gemini-cli@v0 From ce51de3979955179ff8fee4d5f677826cb73585f Mon Sep 17 00:00:00 2001 From: OtonariShunji Date: Wed, 7 Oct 2026 13:44:38 +0900 Subject: [PATCH 06/10] =?UTF-8?q?gemini=E3=83=AC=E3=83=93=E3=83=A5?= =?UTF-8?q?=E3=83=BC=E3=81=AE=E3=83=97=E3=83=AD=E3=83=B3=E3=83=97=E3=83=88?= =?UTF-8?q?=E3=82=92=E8=BF=BD=E5=8A=A0=E3=81=97=E3=81=BE=E3=81=97=E3=81=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/gemini-review.yml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/.github/workflows/gemini-review.yml b/.github/workflows/gemini-review.yml index 5e77216..1c3571a 100644 --- a/.github/workflows/gemini-review.yml +++ b/.github/workflows/gemini-review.yml @@ -19,4 +19,9 @@ jobs: - uses: google-github-actions/run-gemini-cli@v0 with: gemini_api_key: ${{ secrets.GEMINI_API_KEY }} - workflow: pr-review # or issue-triage / on-demand \ No newline at end of file + prompt: | + あなたは極めて優秀なシニアエンジニアです。 + 提出されたコードの差分(Diff)を分析し、以下の観点からレビューしてコメントを日本語で残してください。 + 1. バグの引き金になりそうな潜在的な問題 + 2. パフォーマンスや計算効率の改善点 + 3. コードの可読性やメンテナンス性 \ No newline at end of file From 9407fe0b47344435e02a447a45924c05317e6944 Mon Sep 17 00:00:00 2001 From: OtonariShunji Date: Wed, 7 Oct 2026 13:50:58 +0900 Subject: [PATCH 07/10] =?UTF-8?q?gemini=E3=83=AC=E3=83=93=E3=83=A5?= =?UTF-8?q?=E3=83=BC=E3=81=AE=E3=83=AF=E3=83=BC=E3=82=AF=E3=83=95=E3=83=AD?= =?UTF-8?q?=E3=83=BC=E3=82=92=E6=9B=B4=E6=96=B0=E3=81=97=E3=80=81Gemini=20?= =?UTF-8?q?CLI=E3=81=AE=E5=AE=9F=E8=A1=8C=E3=82=B9=E3=83=86=E3=83=83?= =?UTF-8?q?=E3=83=97=E3=82=92=E6=98=8E=E7=A4=BA=E5=8C=96=E3=81=97=E3=81=BE?= =?UTF-8?q?=E3=81=97=E3=81=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/gemini-review.yml | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/.github/workflows/gemini-review.yml b/.github/workflows/gemini-review.yml index 1c3571a..1b412f7 100644 --- a/.github/workflows/gemini-review.yml +++ b/.github/workflows/gemini-review.yml @@ -16,7 +16,10 @@ jobs: GEMINI_CLI_TRUST_WORKSPACE: "true" steps: - uses: actions/checkout@v4 - - uses: google-github-actions/run-gemini-cli@v0 + + - name: Run Gemini CLI + id: gemini + uses: google-github-actions/run-gemini-cli@v0 with: gemini_api_key: ${{ secrets.GEMINI_API_KEY }} prompt: | @@ -24,4 +27,22 @@ jobs: 提出されたコードの差分(Diff)を分析し、以下の観点からレビューしてコメントを日本語で残してください。 1. バグの引き金になりそうな潜在的な問題 2. パフォーマンスや計算効率の改善点 - 3. コードの可読性やメンテナンス性 \ No newline at end of file + 3. コードの可読性やメンテナンス性 + + - name: Post Comment to PR or Issue + if: ${{ steps.gemini.outputs.response != '' }} + uses: actions/github-script@v7 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + script: | + const response = `${{ steps.gemini.outputs.response }}`; + const issue_number = context.issue.number; + + if (issue_number) { + await github.rest.issues.createComment({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: issue_number, + body: response + }); + } \ No newline at end of file From 18c77a71ff61fe119d5e191db0e6b6659c5ea4c7 Mon Sep 17 00:00:00 2001 From: OtonariShunji Date: Wed, 7 Oct 2026 13:57:34 +0900 Subject: [PATCH 08/10] =?UTF-8?q?gemini=E3=83=AC=E3=83=93=E3=83=A5?= =?UTF-8?q?=E3=83=BC=E3=81=AE=E3=83=AF=E3=83=BC=E3=82=AF=E3=83=95=E3=83=AD?= =?UTF-8?q?=E3=83=BC=E3=82=92=E6=9B=B4=E6=96=B0=E3=81=97=E3=80=81Gemini=20?= =?UTF-8?q?CLI=E3=82=A8=E3=83=BC=E3=82=B8=E3=82=A7=E3=83=B3=E3=83=88?= =?UTF-8?q?=E3=82=92Gemini=E3=82=B3=E3=83=BC=E3=83=89=E3=83=AC=E3=83=93?= =?UTF-8?q?=E3=83=A5=E3=83=BC=E3=83=AF=E3=83=BC=E3=82=AF=E3=83=95=E3=83=AD?= =?UTF-8?q?=E3=83=BC=E3=81=AB=E5=A4=89=E6=9B=B4=E3=81=97=E3=81=BE=E3=81=97?= =?UTF-8?q?=E3=81=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/gemini-review.yml | 58 ++++++++++------------------- 1 file changed, 20 insertions(+), 38 deletions(-) diff --git a/.github/workflows/gemini-review.yml b/.github/workflows/gemini-review.yml index 1b412f7..822ef27 100644 --- a/.github/workflows/gemini-review.yml +++ b/.github/workflows/gemini-review.yml @@ -1,48 +1,30 @@ -name: Gemini CLI Agent +name: Gemini Code Reviewer + on: pull_request: - types: [opened, synchronize, reopened] - issues: - types: [opened] + types: [opened, synchronize] + +permissions: + contents: read + pull-requests: write jobs: - gemini: + review: runs-on: ubuntu-latest - permissions: - contents: read - pull-requests: write - issues: write - env: - GEMINI_CLI_TRUST_WORKSPACE: "true" steps: - - uses: actions/checkout@v4 + - name: Checkout Repository + uses: actions/checkout@v4 - - name: Run Gemini CLI - id: gemini - uses: google-github-actions/run-gemini-cli@v0 + - name: Run Gemini Reviewer + continue-on-error: true + uses: sshnaidm/gemini-code-review-action@v2 with: - gemini_api_key: ${{ secrets.GEMINI_API_KEY }} + gemini-key: ${{ secrets.GEMINI_API_KEY }} + model: 'gemini-2.5-flash' + inline-comment: 'true' prompt: | あなたは極めて優秀なシニアエンジニアです。 - 提出されたコードの差分(Diff)を分析し、以下の観点からレビューしてコメントを日本語で残してください。 - 1. バグの引き金になりそうな潜在的な問題 - 2. パフォーマンスや計算効率の改善点 - 3. コードの可読性やメンテナンス性 - - - name: Post Comment to PR or Issue - if: ${{ steps.gemini.outputs.response != '' }} - uses: actions/github-script@v7 - with: - github-token: ${{ secrets.GITHUB_TOKEN }} - script: | - const response = `${{ steps.gemini.outputs.response }}`; - const issue_number = context.issue.number; - - if (issue_number) { - await github.rest.issues.createComment({ - owner: context.repo.owner, - repo: context.repo.repo, - issue_number: issue_number, - body: response - }); - } \ No newline at end of file + 提出されたコードの差分(Diff)を分析し、問題のある具体的な行に対して修正提案を行ってください。 + 指摘事項ごとに以下のフォーマットでコメントを出力してください: + 1. 潜在的なバグやセキュリティ問題 + 2. パフォーマンス・可読性の改善案 \ No newline at end of file From 8365087f4bfdf4f535d664cdb6dacad7623ad31e Mon Sep 17 00:00:00 2001 From: OtonariShunji Date: Wed, 7 Oct 2026 14:03:41 +0900 Subject: [PATCH 09/10] =?UTF-8?q?gemini=E3=83=AC=E3=83=93=E3=83=A5?= =?UTF-8?q?=E3=83=BC=E3=81=AE=E3=83=AF=E3=83=BC=E3=82=AF=E3=83=95=E3=83=AD?= =?UTF-8?q?=E3=83=BC=E3=82=92=E6=9B=B4=E6=96=B0=E3=81=97=E3=80=81=E5=86=8D?= =?UTF-8?q?=E3=82=AA=E3=83=BC=E3=83=97=E3=83=B3=E6=99=82=E3=81=AE=E3=83=88?= =?UTF-8?q?=E3=83=AA=E3=82=AC=E3=83=BC=E3=82=92=E8=BF=BD=E5=8A=A0=E3=80=81?= =?UTF-8?q?=E3=83=AC=E3=83=93=E3=83=A5=E3=83=BC=E5=87=BA=E5=8A=9B=E3=83=95?= =?UTF-8?q?=E3=82=A9=E3=83=BC=E3=83=9E=E3=83=83=E3=83=88=E3=82=92=E6=94=B9?= =?UTF-8?q?=E5=96=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/gemini-review.yml | 90 +++++++++++++++++++++++++---- 1 file changed, 79 insertions(+), 11 deletions(-) diff --git a/.github/workflows/gemini-review.yml b/.github/workflows/gemini-review.yml index 822ef27..a7e9ee5 100644 --- a/.github/workflows/gemini-review.yml +++ b/.github/workflows/gemini-review.yml @@ -2,7 +2,7 @@ name: Gemini Code Reviewer on: pull_request: - types: [opened, synchronize] + types: [opened, synchronize, reopened] permissions: contents: read @@ -14,17 +14,85 @@ jobs: steps: - name: Checkout Repository uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Get PR Diff + id: diff + run: | + # 親コミットとの差分を取得 + git diff origin/${{ github.base_ref }}...HEAD > pr_diff.patch + echo "has_diff=true" >> $GITHUB_OUTPUT - - name: Run Gemini Reviewer - continue-on-error: true - uses: sshnaidm/gemini-code-review-action@v2 + - name: Run Gemini Review + id: gemini + uses: google-github-actions/run-gemini-cli@v0 with: - gemini-key: ${{ secrets.GEMINI_API_KEY }} - model: 'gemini-2.5-flash' - inline-comment: 'true' + gemini_api_key: ${{ secrets.GEMINI_API_KEY }} prompt: | あなたは極めて優秀なシニアエンジニアです。 - 提出されたコードの差分(Diff)を分析し、問題のある具体的な行に対して修正提案を行ってください。 - 指摘事項ごとに以下のフォーマットでコメントを出力してください: - 1. 潜在的なバグやセキュリティ問題 - 2. パフォーマンス・可読性の改善案 \ No newline at end of file + 以下の git diff を分析し、問題のある箇所に対して行単位のレビューを行ってください。 + + 【出力フォーマット】 + 必ず以下の JSON 配列形式のみで出力してください(Markdownの装飾コードブロックを含めないでください)。 + 指摘がない場合は空配列 `[]` を返してください。 + + [ + { + "path": "ファイルパス", + "line": 変更後の該当行番号(整数), + "body": "指摘内容(1. 潜在的なバグ 2. 改善案)" + } + ] + + 【対象 Diff】 + $(cat pr_diff.patch) + + - name: Post Inline Review Comments + uses: actions/github-script@v7 + env: + GEMINI_RESPONSE: ${{ steps.gemini.outputs.response }} + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + script: | + const rawResponse = process.env.GEMINI_RESPONSE || "[]"; + + // JSONのパース処理(```json などのコードブロックが含まれていた場合のクリーニング) + let cleaned = rawResponse.trim(); + if (cleaned.startsWith("```")) { + cleaned = cleaned.replace(/^```[a-z]*\n?/, "").replace(/\n?```$/, ""); + } + + let comments = []; + try { + comments = JSON.parse(cleaned); + } catch (e) { + console.error("JSONのパースに失敗しました:", e); + console.log("生レスポンス:", rawResponse); + return; + } + + if (!Array.isArray(comments) || comments.length === 0) { + console.log("指摘事項はありませんでした。"); + return; + } + + // GitHub Review APIを使ってインラインコメントを投稿 + const reviewComments = comments.map(c => ({ + path: c.path, + line: Number(c.line), + body: `🤖 **Gemini Review**\n\n${c.body}` + })); + + try { + await github.rest.pulls.createReview({ + owner: context.repo.owner, + repo: context.repo.repo, + pull_number: context.issue.number, + event: 'COMMENT', + comments: reviewComments + }); + console.log(`${reviewComments.length} 件のインラインコメントを投稿しました。`); + } catch (error) { + console.error("レビューコメントの投稿に失敗しました:", error); + } \ No newline at end of file From 54e44e454837b19ac97f6653c348b17db9734f7b Mon Sep 17 00:00:00 2001 From: OtonariShunji Date: Wed, 7 Oct 2026 14:05:41 +0900 Subject: [PATCH 10/10] =?UTF-8?q?gemini=E3=83=AC=E3=83=93=E3=83=A5?= =?UTF-8?q?=E3=83=BC=E3=81=AE=E3=83=AF=E3=83=BC=E3=82=AF=E3=83=95=E3=83=AD?= =?UTF-8?q?=E3=83=BC=E3=81=A7GEMINI=5FCLI=5FTRUST=5FWORKSPACE=E7=92=B0?= =?UTF-8?q?=E5=A2=83=E5=A4=89=E6=95=B0=E3=82=92=E6=98=8E=E7=A4=BA=E7=9A=84?= =?UTF-8?q?=E3=81=AB=E8=A8=AD=E5=AE=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/gemini-review.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/gemini-review.yml b/.github/workflows/gemini-review.yml index a7e9ee5..3f8ba65 100644 --- a/.github/workflows/gemini-review.yml +++ b/.github/workflows/gemini-review.yml @@ -11,6 +11,8 @@ permissions: jobs: review: runs-on: ubuntu-latest + env: + GEMINI_CLI_TRUST_WORKSPACE: "true" steps: - name: Checkout Repository uses: actions/checkout@v4