@@ -14,26 +14,61 @@ When using [`files-changed-only`](inputs-outputs.md#files-changed-only) or
1414[ ` lines-changed-only ` ] ( inputs-outputs.md#lines-changed-only ) to get the list
1515of file changes for a CI event, the following permissions are needed:
1616
17- ``` yaml
18- permissions :
19- contents : read # (1)!
20- ` ` `
17+ === "` #!yaml on: push ` "
18+
19+ For [push events](https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#push)
20+
21+ ```yaml
22+ permissions:
23+ contents: read # (1)!
24+ ```
25+
26+ 1. This permission is also needed to download files if the repository is not
27+ checked out before running cpp-linter.
28+
29+ === "` #!yaml on: pull_request ` "
30+
31+ For [pull_request events](https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#pull_request)
32+
33+ ```yaml
34+ permissions:
35+ contents: read # (1)!
36+ pull-requests: read # (2)!
37+ ```
2138
22- 1. This permission is also needed to download files if the repository is not checked out before
23- running cpp-linter (for both push and pull_request events).
39+ 1. For pull requests, this permission is only needed to download files if
40+ the repository is not checked out before running cpp-linter.
41+ 2. Specifying `#!yaml write` is also sufficient as that is required for
42+
43+ * posting [thread comments](#thread-comments) on pull requests
44+ * posting [pull request reviews](#pull-request-reviews)
2445
2546## Thread Comments
2647
2748The [ ` thread-comments ` ] ( inputs-outputs.md#thread-comments ) feature requires the following permissions:
2849
29- ` ` ` yaml
30- permissions:
31- issues: write # (1)!
32- pull-requests: write # (2)!
33- ` ` `
50+ === "` #!yaml on: push ` "
51+
52+ For [push events](https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#push)
53+
54+ ```yaml
55+ permissions:
56+ metadata: read # (1)!
57+ contents: write # (2)!
58+ ```
59+
60+ 1. needed to fetch existing comments
61+ 2. needed to post or update a commit comment. This also allows us to delete
62+ an outdated comment if needed.
63+
64+ === "` #!yaml on: pull_request ` "
65+
66+ For [pull_request events](https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#pull_request)
3467
35- 1. for [push events](https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#push)
36- 2. for [pull_request events](https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#pull_request)
68+ ```yaml
69+ permissions:
70+ pull-requests: write
71+ ```
3772
3873## Pull Request Reviews
3974
0 commit comments