You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
docs: harden GITHUB_TOKEN permissions in gitStream workflow templates (#850)
* docs: harden GITHUB_TOKEN permissions in gitStream workflow templates
Add `permissions: contents: read` to the generated gitStream workflow
templates and all inline snippets in the installation + troubleshooting
docs. Add a dedicated section explaining the two-token split (workflow
GITHUB_TOKEN vs. gitStream App installation token) and why scoping to
contents: read does not affect any feature.
Covers:
- docs/downloads/gitstream.yml
- docs/downloads/gitstream-lite.yml
- docs/github-installation.md (inline snippets + new section)
- docs/troubleshooting.md (dependabot + lite snippets)
- tutorials/basic-usage-python-repo/.github/workflows/gitstream.yml
- .github/workflows/gitstream.yml (dogfood)
Follows https://github.blog/changelog/2021-04-20-github-actions-control-permissions-for-github_token/
* chore: retrigger CI
Copy file name to clipboardExpand all lines: docs/github-installation.md
+28Lines changed: 28 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -68,6 +68,9 @@ You can set up gitStream for a single repo or your entire GitHub organization. S
68
68
If you're working with a large repository (typically monorepos) and experience timeout issues during GitHub Actions execution, you can use the lite version of gitStream that performs a shallow clone to reduce execution time:
69
69
70
70
```yaml
71
+
permissions:
72
+
contents: read
73
+
71
74
jobs:
72
75
gitStream:
73
76
timeout-minutes: 15
@@ -135,6 +138,9 @@ You can set up gitStream for a single repo or your entire GitHub organization. S
135
138
If you're working with large repositories in your organization (typically monorepos) and experience timeout issues during GitHub Actions execution, you can use the lite version of gitStream that performs a shallow clone to reduce execution time:
136
139
137
140
```yaml
141
+
permissions:
142
+
contents: read
143
+
138
144
jobs:
139
145
gitStream:
140
146
timeout-minutes: 15
@@ -186,6 +192,25 @@ You can set up gitStream for a single repo or your entire GitHub organization. S
186
192
| Read and write access to actions, checks, pull requests, and workflows | Trigger workflows, create and update pull requests and their checks, and modify workflow files |
187
193
| User email | Used to identify users |
188
194
195
+
### Hardening the Workflow `GITHUB_TOKEN`
196
+
197
+
The generated `.github/workflows/gitstream.yml` declares an explicit `permissions:` block that scopes the workflow's built-in `GITHUB_TOKEN` to the minimum required:
198
+
199
+
```yaml
200
+
permissions:
201
+
contents: read
202
+
```
203
+
204
+
This follows GitHub's [least-privilege guidance for `GITHUB_TOKEN`](https://github.blog/changelog/2021-04-20-github-actions-control-permissions-for-github_token/). All remaining scopes default to `none` once any key is set.
205
+
206
+
!!! info "Why `contents: read` is sufficient"
207
+
The gitStream action uses two distinct tokens:
208
+
209
+
- **`GITHUB_TOKEN`** (built into the workflow runner) — used only to clone the repository via `actions/checkout`. Needs `contents: read` on private repos.
210
+
- **gitStream App installation token** — passed through `client_payload` and used by the action for all PR comments, labels, approvals, and checks. Governed by the **GitHub App permissions** documented above, independent of the workflow `permissions:` block.
211
+
212
+
Scoping `GITHUB_TOKEN` down to `contents: read` does not affect any gitStream feature — writes flow through the App token.
213
+
189
214
### Configure gitStream to Block Merges <a name="github-merge-block"></a>
190
215
You can configure GitHub to require gitStream checks to pass before PRs can be merged using [branch protection rules](https://docs.github.com/en/repositories/configuring-branches-and-merges-in-your-repository/defining-the-mergeability-of-pull-requests/about-protected-branches).
191
216
@@ -221,6 +246,9 @@ Follow these steps to ensure gitStream runs on self-hosted GitHub Actions runner
221
246
- Modify the gitStream GitHub Actions workflow file (`.github/workflows/gitstream.yml`) to specify self-hosted runners:
0 commit comments