Skip to content

Commit 78817b0

Browse files
author
Justin Poehnelt
authored
ci: auto-trigger Gemini Code Assist review on PR push (npm#209)
1 parent 3d59b2e commit 78817b0

2 files changed

Lines changed: 80 additions & 0 deletions

File tree

.gemini/config.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
code_review:
2+
comment_severity_threshold: HIGH
3+
pull_request_opened:
4+
help: false
5+
summary: true
6+
code_review: true
7+
include_drafts: false

.github/workflows/automation.yml

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ on:
1919
branches: [main]
2020
pull_request:
2121
types: [opened, synchronize, reopened]
22+
pull_request_review:
23+
types: [submitted]
2224
check_run:
2325
types: [completed]
2426

@@ -99,3 +101,74 @@ jobs:
99101
with:
100102
repo-token: ${{ secrets.GOOGLEWORKSPACE_BOT_TOKEN }}
101103
sync-labels: true
104+
105+
gemini-review:
106+
name: Gemini Review
107+
if: >-
108+
github.event_name == 'pull_request' &&
109+
github.event.action == 'synchronize'
110+
runs-on: ubuntu-latest
111+
concurrency:
112+
group: gemini-review-${{ github.event.pull_request.number }}
113+
cancel-in-progress: true
114+
steps:
115+
- name: Remove reviewed label
116+
uses: actions/github-script@v7
117+
with:
118+
github-token: ${{ secrets.GOOGLEWORKSPACE_BOT_TOKEN }}
119+
script: |
120+
try {
121+
await github.rest.issues.removeLabel({
122+
owner: context.repo.owner,
123+
repo: context.repo.repo,
124+
issue_number: context.payload.pull_request.number,
125+
name: 'gemini: reviewed',
126+
});
127+
} catch (e) {
128+
// Label not present — ignore
129+
}
130+
131+
- name: Debounce
132+
run: sleep 60
133+
134+
- name: Trigger Gemini Code Assist review
135+
uses: actions/github-script@v7
136+
with:
137+
github-token: ${{ secrets.GOOGLEWORKSPACE_BOT_TOKEN }}
138+
script: |
139+
await github.rest.issues.createComment({
140+
owner: context.repo.owner,
141+
repo: context.repo.repo,
142+
issue_number: context.payload.pull_request.number,
143+
body: '/gemini review',
144+
});
145+
146+
gemini-reviewed:
147+
name: Gemini Reviewed
148+
if: >-
149+
github.event_name == 'pull_request_review' &&
150+
github.event.review.user.login == 'gemini-code-assist[bot]'
151+
runs-on: ubuntu-latest
152+
steps:
153+
- name: Add reviewed label if review matches HEAD
154+
uses: actions/github-script@v7
155+
with:
156+
github-token: ${{ secrets.GOOGLEWORKSPACE_BOT_TOKEN }}
157+
script: |
158+
const pr = await github.rest.pulls.get({
159+
owner: context.repo.owner,
160+
repo: context.repo.repo,
161+
pull_number: context.payload.pull_request.number,
162+
});
163+
164+
if (context.payload.review.commit_id !== pr.data.head.sha) {
165+
console.log(`Review is for ${context.payload.review.commit_id} but HEAD is ${pr.data.head.sha} — skipping label`);
166+
return;
167+
}
168+
169+
await github.rest.issues.addLabels({
170+
owner: context.repo.owner,
171+
repo: context.repo.repo,
172+
issue_number: context.payload.pull_request.number,
173+
labels: ['gemini: reviewed'],
174+
});

0 commit comments

Comments
 (0)