Skip to content

Commit bd4efba

Browse files
committed
docs: add fork support documentation for PR review workflow
- Add comprehensive section on extending PR review workflow to support forks - Document simple fork support approach using contributor's own Google auth - Explain GitHub Actions security model for fork-based PRs - Provide implementation approaches from simple to advanced - Include security best practices and resources for pull_request_target - Reference centralized authentication documentation - Reorganize content with clear implementation approaches
1 parent b8dcd5f commit bd4efba

File tree

1 file changed

+66
-0
lines changed

1 file changed

+66
-0
lines changed

examples/workflows/pr-review/README.md

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@ 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+
- [Fork Support Approaches](#fork-support-approaches)
33+
- [1. Simple Fork Support](#1-simple-fork-support)
34+
- [2. Using `pull_request_target` Event](#2-using-pull_request_target-event)
3135

3236
## Overview
3337

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

0 commit comments

Comments
 (0)