11name : ' 🧐 Gemini Pull Request Review'
22
3- # From: https://github.com/google-github-actions/run-gemini-cli/blob/main/examples/workflows/pr-review/gemini-pr-review.yml
4-
53on :
6- pull_request :
7- types :
8- - ' opened'
9- - ' reopened'
4+ # pull_request:
5+ # types:
6+ # - 'opened'
7+ # - 'reopened'
108 issue_comment :
119 types :
1210 - ' created'
13- pull_request_review_comment :
14- types :
15- - ' created'
16- pull_request_review :
17- types :
18- - ' submitted'
11+ # pull_request_review_comment:
12+ # types:
13+ # - 'created'
14+ # pull_request_review:
15+ # types:
16+ # - 'submitted'
1917 workflow_dispatch :
2018 inputs :
2119 pr_number :
@@ -40,11 +38,17 @@ permissions:
4038
4139jobs :
4240 review-pr :
41+ # This condition seeks to ensure the action is only run when it is triggered by a trusted user.
42+ # For private repos, users who have access to the repo are considered trusted.
43+ # For public repos, users who members, owners, or collaborators are considered trusted.
4344 if : |-
4445 github.event_name == 'workflow_dispatch' ||
4546 (
4647 github.event_name == 'pull_request' &&
47- contains(fromJSON('["OWNER", "MEMBER", "COLLABORATOR"]'), github.event.pull_request.author_association)
48+ (
49+ github.event.repository.private == true ||
50+ contains(fromJSON('["OWNER", "MEMBER", "COLLABORATOR"]'), github.event.pull_request.author_association)
51+ )
4852 ) ||
4953 (
5054 (
@@ -55,25 +59,30 @@ jobs:
5559 github.event_name == 'pull_request_review_comment'
5660 ) &&
5761 contains(github.event.comment.body, '@gemini-cli /review') &&
58- contains(fromJSON('["OWNER", "MEMBER", "COLLABORATOR"]'), github.event.comment.author_association)
62+ (
63+ github.event.repository.private == true ||
64+ contains(fromJSON('["OWNER", "MEMBER", "COLLABORATOR"]'), github.event.comment.author_association)
65+ )
5966 ) ||
6067 (
6168 github.event_name == 'pull_request_review' &&
6269 contains(github.event.review.body, '@gemini-cli /review') &&
63- contains(fromJSON('["OWNER", "MEMBER", "COLLABORATOR"]'), github.event.review.author_association)
70+ (
71+ github.event.repository.private == true ||
72+ contains(fromJSON('["OWNER", "MEMBER", "COLLABORATOR"]'), github.event.review.author_association)
73+ )
6474 )
6575 timeout-minutes : 5
6676 runs-on : ' ubuntu-latest'
67-
6877 steps :
6978 - name : ' Checkout PR code'
70- uses : ' actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 ' # ratchet:actions/checkout@v4
79+ uses : ' actions/checkout@ff7abcd0c3c05ccf6adc123a8cd1fd4fb30fb493 ' # ratchet:actions/checkout@v4
7180
7281 - name : ' Generate GitHub App Token'
7382 id : ' generate_token'
7483 if : |-
7584 ${{ vars.APP_ID }}
76- uses : ' actions/create-github-app-token@0f859bf9e69e887678d5bbfbee594437cb440ffe ' # ratchet:actions/create-github-app-token@v2
85+ uses : ' actions/create-github-app-token@a8d616148505b5069dccd32f177bb87d7f39123b ' # ratchet:actions/create-github-app-token@v2
7786 with :
7887 app-id : ' ${{ vars.APP_ID }}'
7988 private-key : ' ${{ secrets.APP_PRIVATE_KEY }}'
@@ -111,14 +120,14 @@ jobs:
111120 } >> "${GITHUB_OUTPUT}"
112121
113122
114- - name : ' Get PR details (issue_comment)'
123+ - name : ' Get PR details (issue_comment & reviews )'
115124 id : ' get_pr_comment'
116125 if : |-
117- ${{ github.event_name == 'issue_comment' }}
126+ ${{ github.event_name == 'issue_comment' || github.event_name == 'pull_request_review' || github.event_name == 'pull_request_review_comment' }}
118127 env :
119128 GITHUB_TOKEN : ' ${{ steps.generate_token.outputs.token || secrets.GITHUB_TOKEN }}'
120- COMMENT_BODY : ' ${{ github.event.comment.body }}'
121- PR_NUMBER : ' ${{ github.event.issue.number }}'
129+ COMMENT_BODY : ' ${{ github.event.comment.body || github.event.review.body }}'
130+ PR_NUMBER : ' ${{ github.event.issue.number || github.event.pull_request.number }}'
122131 run : |-
123132 set -euo pipefail
124133
@@ -163,6 +172,7 @@ jobs:
163172 use_gemini_code_assist : ' ${{ vars.GOOGLE_GENAI_USE_GCA }}'
164173 settings : |-
165174 {
175+ "debug": ${{ fromJSON(env.DEBUG || env.ACTIONS_STEP_DEBUG || false) }},
166176 "maxSessionTurns": 20,
167177 "mcpServers": {
168178 "github": {
@@ -213,7 +223,7 @@ jobs:
213223 ## Steps
214224
215225 Start by running these commands to gather the required data:
216- 1. Run: echo $" {REPOSITORY}" to get the github repository in <OWNER>/<REPO> format
226+ 1. Run: echo "$ {REPOSITORY}" to get the github repository in <OWNER>/<REPO> format
217227 2. Run: echo "${PR_DATA}" to get PR details (JSON format)
218228 3. Run: echo "${CHANGED_FILES}" to get the list of changed files
219229 4. Run: echo "${PR_NUMBER}" to get the PR number
@@ -455,4 +465,4 @@ jobs:
455465 repo: '${{ github.repository }}'.split('/')[1],
456466 issue_number: '${{ steps.get_pr.outputs.pr_number || steps.get_pr_comment.outputs.pr_number }}',
457467 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.'
458- })
468+ })
0 commit comments