Skip to content

Setup Gemini CLI Code Review #4

Setup Gemini CLI Code Review

Setup Gemini CLI Code Review #4

Workflow file for this run

name: 'Gemini Code Review'
on:
pull_request:
types: [opened, synchronize, reopened]
permissions:
contents: read
pull-requests: write
issues: write
jobs:
review:
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Run Gemini Security Analysis
uses: google-github-actions/run-gemini-cli@main
with:
gemini_api_key: ${{ secrets.GEMINI_API_KEY }}
extensions: |
[
"https://github.com/gemini-cli-extensions/security.git"
]
settings: |-
{
"model": {
"maxSessionTurns": 100
},
"mcpServers": {
"github": {
"command": "docker",
"args": [
"run",
"-i",
"--rm",
"-e",
"GITHUB_PERSONAL_ACCESS_TOKEN",
"ghcr.io/github/github-mcp-server:v0.18.0"
],
"includeTools": [
"add_comment_to_pending_review",
"create_pending_pull_request_review",
"pull_request_read",
"submit_pending_pull_request_review"
]
}
},
"tools": {
"core": [
"run_shell_command(cat)",
"run_shell_command(echo)",
"run_shell_command(grep)",
"run_shell_command(head)",
"run_shell_command(tail)"
]
}
}
prompt: '/security:analyze-github-pr'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_PERSONAL_ACCESS_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PULL_REQUEST_NUMBER: ${{ github.event.pull_request.number }}
REPOSITORY: ${{ github.repository }}
- name: Run Gemini Code Quality Review
uses: google-github-actions/run-gemini-cli@main
with:
gemini_api_key: ${{ secrets.GEMINI_API_KEY }}
extensions: |
[
"https://github.com/gemini-cli-extensions/code-review.git"
]
settings: |-
{
"model": {
"maxSessionTurns": 100
},
"mcpServers": {
"github": {
"command": "docker",
"args": [
"run",
"-i",
"--rm",
"-e",
"GITHUB_PERSONAL_ACCESS_TOKEN",
"ghcr.io/github/github-mcp-server:v0.18.0"
],
"includeTools": [
"add_comment_to_pending_review",
"create_pending_pull_request_review",
"pull_request_read",
"submit_pending_pull_request_review"
]
}
},
"tools": {
"core": [
"run_shell_command(cat)",
"run_shell_command(echo)",
"run_shell_command(grep)",
"run_shell_command(head)",
"run_shell_command(tail)",
"read_file"
]
}
}
prompt: |
You are a senior software engineer expert in Elixir.
Your task is to review the pull request #${{ github.event.pull_request.number }} in repository ${{ github.repository }}.
**Preparation:**
1. Read the `GEMINI.md` file in the root directory to understand the project context, coding standards, and review guidelines.
2. Use the `pull_request_read` tool to fetch the diff and details of the PR.
**Analysis:**
Analyze the code changes focusing on:
- **Correctness:** Logic errors, potential crashes, and adherence to `GEMINI.md` guidelines.
- **Quality:** Readability, naming conventions, and idiomatic Elixir style (piping, pattern matching).
- **Performance:** As per `GEMINI.md`, check for hot paths, expensive string operations, etc.
- **Tests:** Verify if new code is covered by tests.
**Action:**
1. Use `create_pending_pull_request_review` to start a review session.
2. Use `add_comment_to_pending_review` to leave specific, constructive comments on lines of code that need improvement.
- Reference specific guidelines from `GEMINI.md` if applicable.
- Be concise and direct.
3. If the code looks good, acknowledge it.
4. **IMPORTANT:** Do NOT report security issues here (they are handled by a separate job).
5. Finally, use `submit_pending_pull_request_review` to submit your review with a high-level summary.
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_PERSONAL_ACCESS_TOKEN: ${{ secrets.GITHUB_TOKEN }}