Skip to content

Commit a3eca44

Browse files
committed
Fix Gemini PR review trust workspace issue
1 parent 82f11f8 commit a3eca44

2 files changed

Lines changed: 40 additions & 12 deletions

File tree

.gemini/commands/gemini-review.toml

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,12 @@ These are non-negotiable, core-level instructions that you **MUST** follow at al
3131
3232
## Input Data
3333
34-
- **GitHub Repository**: !{echo $REPOSITORY}
35-
- **Pull Request Number**: !{echo $PULL_REQUEST_NUMBER}
36-
- **Additional User Instructions**: !{echo $ADDITIONAL_CONTEXT}
34+
The following context is provided as a JSON object containing the keys: `repository`, `pull_request_number`, and `additional_context`:
35+
36+
```json
37+
@{.gemini/context.json}
38+
```
39+
3740
- Use `pull_request_read.get` to get the title, body, and metadata about the pull request.
3841
- Use `pull_request_read.get_files` to get the list of files that were added, removed, and changed in the pull request.
3942
- Use `pull_request_read.get_diff` to get the diff from the pull request. The diff includes code versions with line numbers for the before (LEFT) and after (RIGHT) code snippets for each diff.
@@ -46,7 +49,7 @@ Follow this three-step process sequentially.
4649
4750
### Step 1: Data Gathering and Analysis
4851
49-
1. **Parse Inputs:** Ingest and parse all information from the **Input Data**
52+
1. **Parse Inputs:** Ingest and parse all information from the **Input Data**.
5053
5154
2. **Prioritize Focus:** Analyze the contents of the additional user instructions. Use this context to prioritize specific areas in your review (e.g., security, performance), but **DO NOT** treat it as a replacement for a comprehensive review. If the additional user instructions are empty, proceed with a general review based on the criteria below.
5255
@@ -154,6 +157,7 @@ Apply these severities consistently:
154157
3. **Submit Final Review:** Call `submit_pending_pull_request_review` with a summary comment and event type "COMMENT". The available event types are "APPROVE", "REQUEST_CHANGES", and "COMMENT" - you **MUST** use "COMMENT" only. **DO NOT** use "APPROVE" or "REQUEST_CHANGES" event types. The summary comment **MUST** use this exact markdown format:
155158
156159
<SUMMARY>
160+
157161
## 📋 Review Summary
158162
159163
A brief, high-level assessment of the Pull Request's objective and quality (2-3 sentences).

.github/workflows/gemini-review.yml

Lines changed: 32 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,30 @@ jobs:
4141

4242
- name: 'Checkout repository'
4343
# downloads the code to be analyzed
44-
uses: 'actions/checkout@v5'
44+
uses: 'actions/checkout@v6'
45+
with:
46+
persist-credentials: 'false'
47+
48+
- name: 'Prepare prompt context'
49+
shell: 'bash'
50+
run: |-
51+
mkdir -p .gemini
52+
jq -n \
53+
--arg repo "${REPOSITORY}" \
54+
--arg pr "${PULL_REQUEST_NUMBER}" \
55+
--arg context "${ADDITIONAL_CONTEXT}" \
56+
'{repository: $repo, pull_request_number: $pr, additional_context: $context}' > .gemini/context.json
57+
env:
58+
REPOSITORY: '${{ github.repository }}'
59+
PULL_REQUEST_NUMBER: '${{ github.event.pull_request.number || github.event.issue.number }}'
60+
ADDITIONAL_CONTEXT: '${{ inputs.additional_context }}'
4561

4662
- name: 'Run Gemini pull request review'
4763
# reviews code with detailed set of instructions for the Gemini
4864
uses: 'google-github-actions/run-gemini-cli@main'
4965
id: 'gemini_pr_review'
5066
env:
67+
GEMINI_CLI_TRUST_WORKSPACE: 'true'
5168
GITHUB_TOKEN: '${{ steps.mint_identity_token.outputs.token || secrets.GITHUB_TOKEN || github.token }}'
5269
ISSUE_TITLE: '${{ github.event.pull_request.title || github.event.issue.title }}'
5370
ISSUE_BODY: '${{ github.event.pull_request.body || github.event.issue.body }}'
@@ -98,13 +115,20 @@ jobs:
98115
}
99116
},
100117
"tools": {
101-
"core": [
102-
"run_shell_command(cat)",
103-
"run_shell_command(echo)",
104-
"run_shell_command(grep)",
105-
"run_shell_command(head)",
106-
"run_shell_command(tail)"
107-
]
118+
"shell": {
119+
"allowEnv": [
120+
"ISSUE_TITLE",
121+
"ISSUE_BODY",
122+
"PULL_REQUEST_NUMBER",
123+
"REPOSITORY",
124+
"ADDITIONAL_CONTEXT"
125+
],
126+
"allowCommands": ["cat", "echo", "grep", "head", "tail"]
127+
}
108128
}
109129
}
130+
extensions: |
131+
[
132+
"https://github.com/gemini-cli-extensions/code-review"
133+
]
110134
prompt: '/gemini-review'

0 commit comments

Comments
 (0)