Skip to content

Commit 2f2c901

Browse files
authored
actions: Set permissions for various smaller workflows (#46093)
Mostly through static analysis. A few made use of docs for other actions. See inline comments for the main notes on what things need. Other notes: * `.github/actions/turnstile` - It has docs, may as well mention it (theoretically) needing `actions: read`. * coverage-check: Already had some set, but it turns out it doesn't need most of them anymore. It uses the app token for almost everything instead of the default Actions token. * update-phan-stubs: This one also had permissions set that it doesn't need. It even uses a matticbot token for the checkout, so none needed at all. Also the following already had permissions that seem correct: * build-docker * build-docker-monorepo * post-build
1 parent 14c5850 commit 2f2c901

13 files changed

+59
-6
lines changed

.github/actions/turnstile/README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,10 @@ jobs:
5252
5353
If you want to limit the maximum amount of time spent waiting, use GitHub's [timeout-minutes](https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepstimeout-minutes) on the step. If you want to continue if the timeout expires, use GitHub's [continue-on-error](https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepscontinue-on-error) on the step.
5454
55+
### Permissions
56+
57+
When using `github.token`, this may need the `actions: read` workflow permission.
58+
5559
## How?
5660

5761
Using the current run's run ID, it first hits GitHub's [workflow run API](https://docs.github.com/en/rest/actions/workflow-runs#get-a-workflow-run) to fetch the workflow ID and head branch.

.github/workflows/autotagger.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,13 @@ on:
77
- prerelease
88
- '*/branch-*'
99

10+
permissions:
11+
# ./.github/actions/turnstile
12+
actions: read
13+
# read: actions/checkout
14+
# write: `git push`
15+
contents: write
16+
1017
jobs:
1118
tag:
1219
name: Tag

.github/workflows/check-actions-rate-limit.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ jobs:
66
check:
77
name: Check Actions rate limit
88
runs-on: ubuntu-latest
9+
permissions: {}
910
steps:
1011
- name: Check rate limit
1112
env:

.github/workflows/coverage-check.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ concurrency:
1414
cancel-in-progress: true
1515

1616
permissions:
17-
checks: read
18-
pull-requests: write
19-
statuses: write
17+
# actions/checkout
18+
contents: read
19+
# Everything else uses an app token, so no need for permissions.
2020

2121
jobs:
2222
code-coverage-label:

.github/workflows/delete-mirror-branches.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@ name: Delete mirror branches
22
on:
33
delete:
44

5+
permissions:
6+
# actions/checkout
7+
contents: read
8+
# Deletion step uses secrets.API_TOKEN_GITHUB, so no need for permissions.
9+
510
jobs:
611
delete:
712
name: Delete `${{ github.event.ref }}`

.github/workflows/phpcompatibility-dev.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ concurrency:
1010
group: phpcompatibility-dev-${{ github.event_name }}-${{ github.ref }}
1111
cancel-in-progress: true
1212

13+
permissions:
14+
# actions/checkout
15+
contents: read
16+
1317
env:
1418
COMPOSER_ROOT_VERSION: "dev-trunk"
1519

@@ -18,6 +22,11 @@ jobs:
1822
name: detect changed files
1923
runs-on: ubuntu-latest
2024
timeout-minutes: 1 # 2025-11-06: Successful runs seem to take a few seconds.
25+
permissions:
26+
# actions/checkout
27+
contents: read
28+
# dorny/paths-filter
29+
pull-requests: read
2130
outputs:
2231
php: ${{ steps.filter.outputs.php }}
2332
misc: ${{ steps.filter.outputs.misc }}

.github/workflows/pr-is-up-to-date.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,11 @@ on:
88
- pr-update-to
99
- pr-update-to-projects/**
1010

11+
permissions:
12+
# ./.github/actions/turnstile
13+
actions: read
14+
# Note everything else, including actions/checkout, is using secrets.API_TOKEN_GITHUB, so no need for permissions.
15+
1116
jobs:
1217
check:
1318
name: Check

.github/workflows/renovate.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,11 @@ on:
2323
concurrency:
2424
group: renovate-${{ github.ref }}
2525

26+
permissions:
27+
# actions/checkout
28+
contents: read
29+
# Note renovatebot/github-action is passed secrets.RENOVATE_TOKEN, so no need for permissions.
30+
2631
jobs:
2732
renovate:
2833
name: Renovate

.github/workflows/slack-branch-existence-notification.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@ on:
33
create:
44
delete:
55

6+
permissions:
7+
# actions/checkout
8+
contents: read
9+
610
jobs:
711
notify:
812
name: Notify

.github/workflows/slack-workflow-failed.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ on:
1717
- Update Phan stubs
1818
branches: [ 'trunk', 'prerelease', '*/branch-*' ]
1919

20+
permissions:
21+
# actions/checkout
22+
contents: read
23+
2024
jobs:
2125
notify:
2226
name: Notify failure

0 commit comments

Comments
 (0)