Skip to content

Commit 7b40f15

Browse files
authored
fix(workflows): assign explicit permissions (mdn#38017)
Also documents what they are used for.
1 parent ede91f0 commit 7b40f15

24 files changed

+89
-6
lines changed

.github/workflows/auto-cleanup-bot.yml

+4
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ on:
55
- cron: "0 0 * * *"
66
workflow_dispatch:
77

8+
# No GITHUB_TOKEN permissions, as we only use it to increase API limit.
9+
# We use AUTOMERGE_TOKEN to create the PR.
10+
permissions: {}
11+
812
jobs:
913
fix:
1014
if: github.repository == 'mdn/content'

.github/workflows/auto-merge.yml

+3
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ name: auto-merge
33
on:
44
pull_request_target:
55

6+
# No GITHUB_TOKEN permissions, as we use AUTOMERGE_TOKEN instead.
7+
permissions: {}
8+
69
jobs:
710
auto-merge:
811
runs-on: ubuntu-latest

.github/workflows/idle-issues.yml

+6
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,12 @@ on:
33
schedule:
44
- cron: "49 11,23 * * *"
55

6+
permissions:
7+
# Label issues.
8+
issues: write
9+
# Label pull requests.
10+
pull-requests: write
11+
612
jobs:
713
idle:
814
uses: mdn/workflows/.github/workflows/idle.yml@main

.github/workflows/interfacedata-updater.yml

+3
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ on:
66
- cron: "0 0 * * 6"
77
workflow_dispatch:
88

9+
# No GITHUB_TOKEN permissions, as we use AUTOMERGE_TOKEN instead.
10+
permissions: {}
11+
912
jobs:
1013
update:
1114
if: github.repository == 'mdn/content'

.github/workflows/issue-regex-labeler.yml

+4
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@ on:
33
issues:
44
types: [opened]
55

6+
permissions:
7+
# Label issues.
8+
issues: write
9+
610
jobs:
711
issue-labeler:
812
runs-on: ubuntu-latest

.github/workflows/lock-closed.yml

+8
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,14 @@ on:
33
schedule:
44
- cron: "0 9 1 * *"
55

6+
permissions:
7+
# Lock discussions.
8+
discussions: write
9+
# Lock issues.
10+
issues: write
11+
# Lock pull requests.
12+
pull-requests: write
13+
614
jobs:
715
lock:
816
uses: mdn/workflows/.github/workflows/lock-closed.yml@main

.github/workflows/markdown-lint.yml

+3
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ on:
1313
- .github/workflows/markdown-lint.yml
1414
- .github/workflows/markdownlint-problem-matcher.json
1515

16+
# No GITHUB_TOKEN permissions, as we only use it to increase API limit.
17+
permissions: {}
18+
1619
jobs:
1720
docs:
1821
runs-on: ubuntu-latest

.github/workflows/new-issues.yml

+4
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ on:
66
- reopened
77
- opened
88

9+
permissions:
10+
# Label issues.
11+
issues: write
12+
913
jobs:
1014
label-new-issues:
1115
runs-on: ubuntu-latest

.github/workflows/ping-other-repos.yml

+4
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ name: Ping other repos
1111
on:
1212
push:
1313
branches: [main]
14+
15+
# No GITHUB_TOKEN permissions, as we use REPO_PINGER_MDN_SPEC_LINKS.
16+
permissions: {}
17+
1418
jobs:
1519
ping:
1620
# Don't run in forks, or when Dependabot merges a PR.

.github/workflows/pr-check-lint_content.yml

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ on:
1010
- "files/**/*.md"
1111

1212
permissions:
13+
# Compare commits and add reviewdog comments.
1314
pull-requests: write
1415

1516
concurrency:

.github/workflows/pr-check_cspell_lists.yml

+3
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ on:
77
paths:
88
- .vscode/dictionaries/*
99

10+
# No GITHUB_TOKEN permissions, as we don't use it.
11+
permissions: {}
12+
1013
jobs:
1114
docs:
1215
runs-on: ubuntu-latest

.github/workflows/pr-check_javascript.yml

+3
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ on:
1010
- "**/*.mjs"
1111
- .github/workflows/pr-check_javascript.yml
1212

13+
# No GITHUB_TOKEN permissions, as we only use it to increase API limit.
14+
permissions: {}
15+
1316
jobs:
1417
lint-js:
1518
runs-on: ubuntu-latest

.github/workflows/pr-check_json.yml

+3
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ on:
1010
- "**/*.jsonc"
1111
- .github/workflows/pr-check_json.yml
1212

13+
# No GITHUB_TOKEN permissions, as we only use it to increase API limit.
14+
permissions: {}
15+
1316
jobs:
1417
lint-json:
1518
runs-on: ubuntu-latest

.github/workflows/pr-check_redirects.yml

+3
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ on:
55
branches:
66
- main
77

8+
# No GITHUB_TOKEN permissions, as we only use it to increase API limit.
9+
permissions: {}
10+
811
jobs:
912
check-redirects:
1013
runs-on: ubuntu-latest

.github/workflows/pr-check_scripts.yml

+3
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ on:
1010
- yarn.lock
1111
- .github/workflows/pr-check_scripts.yml
1212

13+
# No GITHUB_TOKEN permissions, as we only use it to increase API limit.
14+
permissions: {}
15+
1316
jobs:
1417
up-to-date-check:
1518
runs-on: ubuntu-latest

.github/workflows/pr-check_url-issues.yml

+3
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ on:
77
paths:
88
- "files/**/*.md"
99

10+
# No GITHUB_TOKEN permissions, as we don't use it.
11+
permissions: {}
12+
1013
jobs:
1114
check_url_issues:
1215
#if: github.repository == 'mdn/content'

.github/workflows/pr-check_yml.yml

+3
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ on:
1010
- "**/*.yml"
1111
- .github/workflows/pr-check_yml.yml
1212

13+
# No GITHUB_TOKEN permissions, as we only use it to increase API limit.
14+
permissions: {}
15+
1316
jobs:
1417
lint-yml:
1518
runs-on: ubuntu-latest

.github/workflows/pr-labeler.yml

+3
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,11 @@ on:
44
- pull_request_target
55

66
permissions:
7+
# Patch issues, see: https://github.com/CodelyTV/pr-size-labeler/pull/89
78
issues: write
9+
# Label pull requests.
810
pull-requests: write
11+
# Fetch files (used by actions/labeler to get config).
912
contents: read
1013

1114
jobs:

.github/workflows/pr-rebase-needed.yml

+4
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ on:
55
pull_request_target:
66
types: [synchronize]
77

8+
permissions:
9+
# Label pull requests.
10+
pull-requests: write
11+
812
jobs:
913
label-rebase-needed:
1014
uses: mdn/workflows/.github/workflows/pr-rebase-needed.yml@main

.github/workflows/pr-review-companion.yml

+6
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,12 @@ on:
1111
types:
1212
- completed
1313

14+
permissions:
15+
# Download artifact.
16+
actions: read
17+
# Post comment in pull request.
18+
pull-requests: write
19+
1420
jobs:
1521
review:
1622
runs-on: ubuntu-latest

.github/workflows/pr-test-legacy.yml

+4-3
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,14 @@ on:
1111
branches:
1212
- main
1313

14+
permissions:
15+
# Compare two commits.
16+
contents: read
17+
1418
jobs:
1519
tests:
1620
if: github.repository == 'mdn/content'
1721
runs-on: ubuntu-latest
18-
# Set the permissions to `read-all`, preventing the workflow from
19-
# any accidental write access to the repository.
20-
permissions: read-all
2122
env:
2223
BASE_SHA: ${{ github.event.pull_request.base.sha }}
2324
HEAD_SHA: ${{ github.event.pull_request.head.sha }}

.github/workflows/pr-test.yml

+4-3
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,14 @@ on:
1111
branches:
1212
- main
1313

14+
permissions:
15+
# Compare two commits.
16+
contents: read
17+
1418
jobs:
1519
tests:
1620
if: github.repository == 'mdn/content'
1721
runs-on: ubuntu-latest
18-
# Set the permissions to `read-all`, preventing the workflow from
19-
# any accidental write access to the repository.
20-
permissions: read-all
2122
env:
2223
BASE_SHA: ${{ github.event.pull_request.base.sha }}
2324
HEAD_SHA: ${{ github.event.pull_request.head.sha }}

.github/workflows/spelling-check-bot.yml

+4
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ on:
55
- cron: "0 0 * * mon"
66
workflow_dispatch:
77

8+
permissions:
9+
# Create issue.
10+
issues: write
11+
812
jobs:
913
sync:
1014
if: github.repository == 'mdn/content'

.github/workflows/system-file-changes.yml

+3
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ on:
1010
- package.json
1111
- yarn.lock
1212

13+
# No GITHUB_TOKEN permissions, as we don't use it.
14+
permissions: {}
15+
1316
jobs:
1417
block:
1518
# This makes sure it only runs on our origin repo

0 commit comments

Comments
 (0)