Skip to content

Commit cefad2a

Browse files
committed
feat: expand GitHub Actions permissions to include PR list and granular git commands
1 parent 2271b3b commit cefad2a

1 file changed

Lines changed: 49 additions & 20 deletions

File tree

.github/workflows/gemini-pr-review.yml

Lines changed: 49 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -96,12 +96,19 @@ jobs:
9696
"run_shell_command(gh pr view)",
9797
"run_shell_command(gh pr diff)",
9898
"run_shell_command(gh pr comment)",
99+
"run_shell_command(gh pr list)",
99100
"run_shell_command(cat)",
100101
"run_shell_command(head)",
101102
"run_shell_command(tail)",
102103
"run_shell_command(grep)",
103104
"run_shell_command(find)",
104-
"run_shell_command(git)",
105+
"run_shell_command(git checkout)",
106+
"run_shell_command(git add)",
107+
"run_shell_command(git commit)",
108+
"run_shell_command(git push)",
109+
"run_shell_command(git status)",
110+
"run_shell_command(git branch)",
111+
"run_shell_command(git fetch)",
105112
"list_directory",
106113
"read_file",
107114
"read_many_files",
@@ -120,25 +127,47 @@ jobs:
120127
"sandbox": false
121128
}
122129
prompt: |
123-
You are an expert code reviewer. You have access to shell commands to gather PR information and perform the review.
124-
125-
IMPORTANT: Use the available shell commands to gather information. Do not ask for information to be provided.
126-
127-
Start by running these commands to gather the required data:
128-
1. Run: echo "$PR_DATA" to get PR details (JSON format)
129-
2. Run: echo "$CHANGED_FILES" to get the list of changed files
130-
3. Run: echo "$PR_NUMBER" to get the PR number
131-
4. Run: echo "$ADDITIONAL_INSTRUCTIONS" to see any specific review instructions from the user
132-
5. Run: gh pr diff $PR_NUMBER to see the full diff
133-
6. For any specific files, use: cat filename, head -50 filename, or tail -50 filename
134-
135-
Additional Review Instructions:
136-
If ADDITIONAL_INSTRUCTIONS contains text, prioritize those specific areas or focus points in your review.
137-
Common instruction examples: "focus on security", "check performance", "review error handling", "check for breaking changes"
138-
139-
Once you have the information, provide a comprehensive code review by:
140-
1. Writing your review to a file: write_file("review.md", "<your detailed review feedback here>")
141-
2. Posting the review: gh pr comment $PR_NUMBER --body-file review.md --repo $REPOSITORY
130+
You are an expert code reviewer and AI assistant for Pull Requests. You can review code AND make modifications to improve the PR.
131+
132+
**PR Details:**
133+
- PR Number: #${PR_NUMBER}
134+
- Repository: ${REPOSITORY}
135+
- Additional Instructions: ${ADDITIONAL_INSTRUCTIONS}
136+
137+
**CRITICAL: When making code modifications, follow this EXACT workflow:**
138+
139+
**STEP 1: Analyze the PR**
140+
- Use: `echo "$PR_DATA"` to get PR details (JSON format)
141+
- Use: `echo "$CHANGED_FILES"` to get changed files list
142+
- Use: `gh pr diff ${PR_NUMBER}` to see the full diff
143+
- Use: `gh pr view ${PR_NUMBER} --json title,body,headRefName` to get PR info
144+
- Analyze the code changes thoroughly
145+
146+
**STEP 2: If Code Improvements Are Needed**
147+
**IMPORTANT:** DO NOT create a new branch! Work on the EXISTING PR branch.
148+
- Use: `git fetch origin` to get latest changes
149+
- Get PR branch name: `gh pr view ${PR_NUMBER} --json headRefName`
150+
- Switch to PR branch: `git checkout BRANCH_NAME` (use actual branch name from PR)
151+
- Use: `git pull origin BRANCH_NAME` to get latest PR changes
152+
153+
**STEP 3: Make Code Modifications**
154+
- Use `read_file` to examine existing code
155+
- Use `write_file` or `replace` to make improvements
156+
- Use `search_file_content` to find related code
157+
- Make focused, targeted improvements to the PR
158+
159+
**STEP 4: Test Changes (if applicable)**
160+
- Run relevant tests if test files exist
161+
- Use `run_shell_command` to execute test commands
162+
163+
**STEP 5: Commit and Push Changes to EXISTING PR Branch**
164+
- Use: `git add .` (or specific files)
165+
- Use: `git commit -m "Gemini: [PR #${PR_NUMBER}] Brief description of improvements"`
166+
- Use: `git push origin BRANCH_NAME` (push to EXISTING PR branch)
167+
168+
**STEP 6: Review and Comment on PR**
169+
Write comprehensive review and post comment with your analysis and any improvements made.
170+
Use: `gh pr comment ${PR_NUMBER} -b "MESSAGE"`
142171
143172
Review Guidelines:
144173
- Focus on code quality, security, performance, and maintainability

0 commit comments

Comments
 (0)