Skip to content

Commit 4c2eefc

Browse files
authored
Merge pull request #641 from wollew/clarify_permissions
2 parents 7188638 + f3db00a commit 4c2eefc

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

README.md

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,16 @@ is done in 2 steps:
9292
untrusted code
9393
2. From a trusted workflow, publish the comment on the PR
9494

95+
The write permissions in the `CI` workflow below are intentional. They are
96+
used when the PR is trusted enough, usually because it comes from the same
97+
repository, for this workflow to publish or update the comment directly.
98+
When that happens, the second workflow can be skipped.
99+
For `pull_request` runs coming from forks, which are untrusted by default,
100+
GitHub downgrades requested write permissions to read-only unless the
101+
repository is explicitly configured to send write tokens to workflows from
102+
pull requests. In other words, these settings do not grant write access to
103+
untrusted code.
104+
95105
```yaml
96106
# .github/workflows/ci.yml
97107
name: CI
@@ -107,12 +117,11 @@ jobs:
107117
name: Run tests & display coverage
108118
runs-on: ubuntu-latest
109119
permissions:
110-
# Gives the action the necessary permissions for publishing new
111-
# comments in pull requests.
120+
# Allows the action to publish new comments directly on trusted PRs.
121+
# Forked pull_request runs are downgraded to read-only by GitHub.
112122
pull-requests: write
113-
# Gives the action the necessary permissions for pushing data to the
114-
# python-coverage-comment-action branch, and for editing existing
115-
# comments (to avoid publishing multiple comments in the same PR)
123+
# Allows updating the python-coverage-comment-action branch and editing
124+
# existing comments when direct publication is allowed.
116125
contents: write
117126
steps:
118127
- uses: actions/checkout@v4

0 commit comments

Comments
 (0)