@@ -28,6 +28,9 @@ This document explains how to use the Gemini CLI on GitHub to automatically revi
2828 - [ Security-Focused Review] ( #security-focused-review )
2929 - [ Performance Review] ( #performance-review )
3030 - [ Breaking Changes Check] ( #breaking-changes-check )
31+ - [ Extending to Support Forks] ( #extending-to-support-forks )
32+ - [ 1. Simple Fork Support] ( #1-simple-fork-support )
33+ - [ 2. Using ` pull_request_target ` Event] ( #2-using-pull_request_target-event )
3134
3235## Overview
3336
@@ -237,3 +240,63 @@ The AI prompt can be customized to:
237240```
238241@gemini-cli /review look for potential breaking changes and API compatibility
239242```
243+
244+ ## Extending to Support Forks
245+
246+ By default, this workflow is configured to work with pull requests from branches
247+ within the same repository, and does not allow the `pr-review` workflow to be
248+ triggered for pull requests from branches from forks. This is done because forks
249+ can be created from bad actors, and enabling this workflow to run on branches
250+ from forks could enable bad actors to access secrets.
251+
252+ This behavior may not be ideal for all use cases - such as private repositories.
253+ To enable the `pr-review` workflow to run on branches in forks, there are several
254+ approaches depending on your authentication setup and security requirements.
255+ Please refer to the GitHub documentation links provided below for
256+ the security and access considerations of doing so.
257+
258+ Depending on your security requirements and use case, you can choose from these
259+ approaches:
260+
261+ #### 1. Simple Fork Support
262+
263+ This could work for repositories where contributors can provide their own Google
264+ authentication in their forks.
265+
266+ **How it works**: If forks have their own Google authentication configured, you
267+ can enable fork support by simply removing the fork restriction condition in the
268+ dispatch workflow.
269+
270+ **Implementation**:
271+ 1. Remove the fork restriction in `gemini-dispatch.yml`:
272+ ```yaml
273+ # Change this condition to remove the fork check
274+ if: |-
275+ (
276+ github.event_name == 'pull_request'
277+ # Remove this line: && github.event.pull_request.head.repo.fork == false
278+ ) || (
279+ # ... rest of conditions
280+ )
281+ ```
282+
283+ 2 . Document for contributors that they need to configure Google authentication
284+ in their fork as described in the
285+ [ Authentication documentation] ( ../../../docs/authentication.md ) .
286+
287+
288+ #### 2. Using ` pull_request_target ` Event
289+
290+ This could work for private repositories where you want to provide API access
291+ centrally.
292+
293+ ** Important Security Note** : Using ` pull_request_target ` can introduce security
294+ vulnerabilities if not handled with extreme care. Because it runs in the context
295+ of the base repository, it has access to secrets and other sensitive data.
296+ Always ensure you are following security best practices, such as those outlined
297+ in the linked resources, to prevent unauthorized access or code execution.
298+
299+ - ** Resources** :
300+ - [ GitHub Docs: Using pull_request_target] ( https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#pull_request_target ) .
301+ - [ Security Best Practices for pull_request_target] ( https://securitylab.github.com/research/github-actions-preventing-pwn-requests/ ) .
302+ - [ Safe Workflows for Forked Repositories] ( https://github.blog/2020-08-03-github-actions-improvements-for-fork-and-pull-request-workflows/ ) .
0 commit comments