Skip to content

Commit 2f6652e

Browse files
authored
feat: add failure notification to pr review workflow (#59)
This adds a new step to the PR review workflow that posts a comment to the PR if the Gemini CLI review fails. This provides better visibility into workflow failures.
1 parent a579461 commit 2f6652e

2 files changed

Lines changed: 18 additions & 4 deletions

File tree

workflows/pr-review/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ The PR Review workflow uses Google's Gemini AI to provide comprehensive code rev
4141
- **Positive Highlights**: Acknowledges good practices and well-written code
4242
- **Custom Instructions**: Support for specific review focus areas
4343
- **Structured Output**: Consistent markdown format for easy reading
44+
- **Failure Notifications**: Posts a comment on the PR if the review process fails.
4445

4546
## Setup
4647

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

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,15 +66,13 @@ jobs:
6666

6767
steps:
6868
- name: 'Checkout PR code'
69-
uses: 'actions/checkout@v4'
70-
with:
71-
fetch-depth: 0
69+
uses: 'actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683' # ratchet:actions/checkout@v4
7270

7371
- name: 'Generate GitHub App Token'
7472
id: 'generate_token'
7573
if: |-
7674
${{ vars.APP_ID }}
77-
uses: 'actions/create-github-app-token@v1'
75+
uses: 'actions/create-github-app-token@df432ceedc7162793a195dd1713ff69aefc7379e' # ratchet:actions/create-github-app-token@v2
7876
with:
7977
app-id: '${{ vars.APP_ID }}'
8078
private-key: '${{ secrets.APP_PRIVATE_KEY }}'
@@ -144,6 +142,7 @@ jobs:
144142
145143
- name: 'Run Gemini PR Review'
146144
uses: 'google-github-actions/run-gemini-cli@main'
145+
id: 'gemini_pr_review'
147146
env:
148147
GITHUB_TOKEN: '${{ steps.generate_token.outputs.token || secrets.GITHUB_TOKEN }}'
149148
PR_NUMBER: '${{ steps.get_pr.outputs.pr_number || steps.get_pr_comment.outputs.pr_number }}'
@@ -302,3 +301,17 @@ jobs:
302301
- List any questions you have about the implementation
303302
- Clarifications needed from the author
304303
'''
304+
305+
- name: 'Post PR review failure comment'
306+
if: |-
307+
${{ failure() && steps.gemini_pr_review.outcome == 'failure' }}
308+
uses: 'actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea'
309+
with:
310+
github-token: '${{ steps.generate_token.outputs.token || secrets.GITHUB_TOKEN }}'
311+
script: |
312+
github.rest.issues.createComment({
313+
owner: '${{ github.repository }}'.split('/')[0],
314+
repo: '${{ github.repository }}'.split('/')[1],
315+
issue_number: '${{ steps.get_pr.outputs.pr_number || steps.get_pr_comment.outputs.pr_number }}',
316+
body: 'There is a problem with the Gemini CLI PR review. Please check the [action logs](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}) for details.'
317+
})

0 commit comments

Comments
 (0)