|
19 | 19 | branches: [main] |
20 | 20 | pull_request: |
21 | 21 | types: [opened, synchronize, reopened] |
| 22 | + pull_request_review: |
| 23 | + types: [submitted] |
22 | 24 | check_run: |
23 | 25 | types: [completed] |
24 | 26 |
|
@@ -99,3 +101,74 @@ jobs: |
99 | 101 | with: |
100 | 102 | repo-token: ${{ secrets.GOOGLEWORKSPACE_BOT_TOKEN }} |
101 | 103 | 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