Skip to content

Commit decaf5a

Browse files
committed
Add auto-comment-gemini-review.yml workflow
1 parent e3d0661 commit decaf5a

File tree

1 file changed

+51
-0
lines changed

1 file changed

+51
-0
lines changed
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# Place this file in: .github/workflows/auto-comment-gemini-review.yml
2+
3+
name: Auto Comment Gemini Review
4+
5+
on:
6+
push:
7+
branches:
8+
- '**' # Trigger on push to any branch
9+
10+
jobs:
11+
comment-gemini-review:
12+
runs-on: ubuntu-latest
13+
permissions:
14+
pull-requests: write # Required to comment on pull requests
15+
contents: read # Required to access repository contents
16+
17+
steps:
18+
- name: Checkout repository
19+
uses: actions/checkout@v4
20+
21+
- name: Get branch name
22+
id: branch
23+
run: echo "branch=${GITHUB_REF#refs/heads/}" >> $GITHUB_OUTPUT
24+
25+
- name: Check for open pull requests
26+
id: check-pr
27+
env:
28+
GITHUB_TOKEN: ${{ secrets.GEMINI_REVIEW_TOKEN }} # Use organization secret
29+
run: |
30+
PR_JSON=$(gh api \
31+
-H "Accept: application/vnd.github+json" \
32+
"/repos/${{ github.repository }}/pulls?head=${{ github.repository_owner }}:${{ steps.branch.outputs.branch }}&state=open")
33+
PR_COUNT=$(echo "$PR_JSON" | jq length)
34+
if [ "$PR_COUNT" -gt 0 ]; then
35+
PR_NUMBER=$(echo "$PR_JSON" | jq -r '.[0].number')
36+
echo "Found open PR #$PR_NUMBER"
37+
echo "pr_number=$PR_NUMBER" >> $GITHUB_OUTPUT
38+
else
39+
echo "No open PR found for branch ${{ steps.branch.outputs.branch }}"
40+
echo "pr_number=" >> $GITHUB_OUTPUT
41+
fi
42+
43+
- name: Comment on pull request
44+
if: steps.check-pr.outputs.pr_number != ''
45+
env:
46+
GITHUB_TOKEN: ${{ secrets.GEMINI_REVIEW_TOKEN }} # Use organization secret
47+
run: |
48+
gh api \
49+
-H "Accept: application/vnd.github+json" \
50+
"/repos/${{ github.repository }}/issues/${{ steps.check-pr.outputs.pr_number }}/comments" \
51+
-f body='/gemini review'

0 commit comments

Comments
 (0)