Skip to content

Commit 28ecf85

Browse files
add permissions to github workflows (#9746)
* add permissions to github workflows update all the github workflows to specify the set of permissions they require, ensuring that each workflow includes the least privileges it required to complete the task * added comments for write permissions * fix wrong write permissions set * update wrong comments * update wrong write permissions
1 parent 81bd41c commit 28ecf85

19 files changed

+78
-6
lines changed

.github/workflows/c3-dependabot-versioning-prs.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@ on:
44
paths:
55
- "packages/create-cloudflare/src/frameworks/package.json"
66

7+
permissions:
8+
# content:write permission needed to update add changesets to dependabot PRs
9+
# (see tools/dependabot/generate-dependabot-pr-changesets.ts)
10+
contents: write
11+
712
jobs:
813
generate-changeset:
914
runs-on: ubuntu-22.04

.github/workflows/c3-e2e.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ on:
33
merge_group:
44
pull_request:
55

6+
permissions:
7+
contents: read
8+
69
env:
710
# TODO: switch back to 20.x onces [email protected] includes a fix for https://github.com/nodejs/node/issues/57869
811
NODE_VERSION: 22

.github/workflows/changesets.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ on:
55
branches:
66
- main
77

8+
permissions:
9+
contents: read
10+
# note: no write permissions are needed since the workflow uses GH_ACCESS_TOKEN instead of GITHUB_TOKEN
11+
812
jobs:
913
release:
1014
if: ${{ github.repository_owner == 'cloudflare' }}

.github/workflows/deploy-pages-previews.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,11 @@ on:
2020
pull_request:
2121
types: [synchronize, opened, reopened, labeled, unlabeled]
2222

23+
permissions:
24+
contents: read
25+
# pull-request:write permission needed so that the workflow can comment on PRs
26+
pull-requests: write
27+
2328
jobs:
2429
deploy-pages-projects:
2530
# Only run this on PRs that are for the "cloudflare" org and not "from" `main`

.github/workflows/e2e-project-cleanup.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
11
# This workflow cleans up any leftover projects created by e2e runs.
22

33
name: E2E Project Cleanup
4+
45
on:
56
workflow_dispatch:
67
schedule:
78
- cron: "0 3 * * *" # Run at 3am each day
9+
10+
permissions:
11+
contents: read
12+
813
jobs:
914
cleanup:
1015
timeout-minutes: 30

.github/workflows/e2e.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ on:
44
merge_group:
55
pull_request:
66

7+
permissions:
8+
contents: read
9+
710
jobs:
811
e2e-wrangler-test:
912
name: ${{ format('Wrangler ({0})', matrix.description) }}

.github/workflows/holopin.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ on:
55
- closed
66
- labeled
77

8+
permissions:
9+
# pull-request:write permission needed so that the workflow can comment on PRs
10+
pull-requests: write
11+
812
jobs:
913
issue_lava_lamp_holobyte:
1014
name: Issue Lava Lamp Holobyte

.github/workflows/hotfix-release.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
name: Release a hotfix
2+
23
on:
34
workflow_dispatch:
45
inputs:
@@ -14,6 +15,10 @@ on:
1415
type: string
1516
default: hotfix
1617
required: true
18+
19+
permissions:
20+
contents: read
21+
1722
jobs:
1823
hotfix-release:
1924
name: Hotfix Release

.github/workflows/issues.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ on:
44
issues:
55
types: [opened, transferred]
66

7+
permissions:
8+
# issues:write permission needed so that the workflow can manage issues
9+
issues: write
10+
711
jobs:
812
add-to-project:
913
name: Add issue to project

.github/workflows/miniflare-dependabot-versioning-prs.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,15 @@
11
name: "Miniflare - Generate changesets for dependabot PRs"
2+
23
on:
34
pull_request_target:
45
paths:
56
- "packages/miniflare/package.json"
67

8+
permissions:
9+
# content:write permission needed to update add changesets to dependabot PRs
10+
# (see tools/dependabot/generate-dependabot-pr-changesets.ts)
11+
contents: write
12+
713
jobs:
814
generate-changeset:
915
runs-on: ubuntu-22.04

0 commit comments

Comments
 (0)