Skip to content

Commit b379920

Browse files
committed
begin documenting permissions
resolves #17 This is mostly copied and pasted from cpp-linter-action's corresponding doc. The parts about PR reviews have been commented out and should be un-commented when addressing #9.
1 parent 9dde123 commit b379920

File tree

2 files changed

+89
-0
lines changed

2 files changed

+89
-0
lines changed

docs/src/SUMMARY.md

+1
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@
44

55
- [Introduction](./index.md)
66
- [Command Line Interface](./cli.md)
7+
- [Token Permissions](./permissions.md)

docs/src/permissions.md

+88
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
<!-- markdownlint-disable MD024 -->
2+
3+
# Token Permissions
4+
5+
This is an exhaustive list of required permissions organized by features.
6+
7+
> [!important]
8+
> The `GITHUB_TOKEN` environment variable should be supplied when running on a private repository.
9+
> Otherwise the runner does not not have the privileges needed for the features mentioned here.
10+
>
11+
> See also [Authenticating with the `GITHUB_TOKEN`](https://docs.github.com/en/actions/reference/authentication-in-a-workflow)
12+
13+
[push-events]: https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#push
14+
[pr-events]: https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#pull_request
15+
16+
## File Changes
17+
18+
When using [`--files-changed-only`](cli.md#-f---files-changed-only) or
19+
[`--lines-changed-only`](cli.md#-l---lines-changed-only) to get the list
20+
of file changes for a CI event, the following permissions are needed:
21+
22+
### Push
23+
24+
For [`push` events][push-events].
25+
26+
```yaml
27+
permissions:
28+
contents: read
29+
```
30+
31+
The `contents` permission is also needed to download files if the repository is not
32+
checked out before running cpp-linter.
33+
34+
### Pull Request
35+
36+
For [`pull_request` events][pr-events].
37+
38+
```yaml
39+
permissions:
40+
contents: read
41+
pull-requests: read
42+
```
43+
44+
For pull requests, the `contents` permission is only needed to download files if
45+
the repository is not checked out before running cpp-linter.
46+
47+
* Specifying `write` to the `pull-requests` permission is also sufficient as that is
48+
required for
49+
* posting [thread comments](#thread-comments) on pull requests
50+
<!-- * posting [pull request reviews](#pull-request-reviews) -->
51+
52+
## Thread Comments
53+
54+
The [`--thread-comments`](cli.md#-g---thread-comments) feature requires the following permissions:
55+
56+
### Push
57+
58+
For [`push` events][push-events].
59+
60+
```yaml
61+
permissions:
62+
metadata: read
63+
contents: write
64+
```
65+
66+
* The `metadata` permission is needed to fetch existing comments.
67+
* The `contents` permission is needed to post or update a commit comment.
68+
This also allows us to delete an outdated comment if needed.
69+
70+
### Pull_request
71+
72+
For [`pull_request` events][pr-events].
73+
74+
```yaml
75+
permissions:
76+
pull-requests: write
77+
```
78+
79+
<!--
80+
## Pull Request Reviews
81+
82+
The [`tidy-review`](cli.md#-t---tidy-review), [`format-review`](cli.md#-f---format-review), and [`passive-reviews`](cli.md#-p---passive-reviews) features require the following permissions:
83+
84+
```yaml
85+
permissions:
86+
pull-requests: write
87+
```
88+
-->

0 commit comments

Comments
 (0)