Skip to content

An open source design system that's fully customizable and agent ready

TypeScript

chore(ci): scope workflow permissions per-job (least-privilege) (#2192)

Gerard Roviradf608a624c5d
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 8bda00c124..a9c4275398 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -12,12 +12,7 @@ on:
branches: ["main"]
merge_group:
-permissions:
- contents: write
- pages: write
- id-token: write
- pull-requests: write
- actions: read
+permissions: {}
concurrency:
group: "ci-${{ github.event.merge_group.head_sha || github.head_ref }}"
@@ -29,6 +24,8 @@ jobs:
check-scope:
if: github.event_name == 'pull_request'
runs-on: ubuntu-latest
+ permissions:
+ contents: read
outputs:
docsite_only: ${{ steps.scope.outputs.docsite_only }}
steps:
@@ -57,6 +54,8 @@ jobs:
# Docsite data extraction tests — always runs, fast (~2s)
docsite-test:
runs-on: ubuntu-latest
+ permissions:
+ contents: read
steps:
- uses: actions/checkout@v6
@@ -76,6 +75,8 @@ jobs:
needs: [check-scope]
if: github.event_name == 'pull_request' && needs.check-scope.outputs.docsite_only != 'true'
runs-on: ubuntu-latest
+ permissions:
+ contents: read
outputs:
has_components: ${{ steps.check.outputs.has_components }}
steps:
@@ -95,6 +96,8 @@ jobs:
test:
needs: [check-scope]
runs-on: ubuntu-latest
+ permissions:
+ contents: read
steps:
- name: Skip for docsite-only changes
if: needs.check-scope.outputs.docsite_only == 'true'
@@ -132,6 +135,8 @@ jobs:
build:
needs: [check-scope]
runs-on: ubuntu-latest
+ permissions:
+ contents: read
outputs:
storybook_url: ${{ steps.urls.outputs.storybook_url }}
short_hash: ${{ steps.urls.outputs.short_hash }}
@@ -253,6 +258,8 @@ jobs:
if: github.event_name == 'pull_request' && needs.check-scope.outputs.docsite_only != 'true'
needs: [build, check-scope]
runs-on: ubuntu-latest
+ permissions:
+ contents: write
concurrency:
group: "pr-preview-${{ needs.build.outputs.pr_number }}"
cancel-in-progress: true
@@ -318,6 +325,9 @@ jobs:
if: github.event_name == 'pull_request' && needs.check-scope.outputs.docsite_only != 'true'
needs: [build, check-scope]
runs-on: ubuntu-latest
+ permissions:
+ contents: read
+ pull-requests: write
steps:
- name: Checkout
uses: actions/checkout@v6
@@ -390,6 +400,8 @@ jobs:
needs: [build, check-components]
if: github.event_name == 'pull_request' && needs.check-components.outputs.has_components == 'true'
runs-on: ubuntu-latest
+ permissions:
+ contents: read
steps:
- name: Checkout
uses: actions/checkout@v6
@@ -434,6 +446,9 @@ jobs:
needs: [build, check-components, pr-a11y]
if: always() && github.event_name == 'pull_request' && needs.build.result == 'success' && needs.check-components.outputs.has_components == 'true'
runs-on: ubuntu-latest
+ permissions:
+ contents: read
+ pull-requests: write
steps:
- name: Checkout
uses: actions/checkout@v6
diff --git a/.github/workflows/cleanup-previews.yml b/.github/workflows/cleanup-previews.yml
index 8af73a15d7..29d574030f 100644
--- a/.github/workflows/cleanup-previews.yml
+++ b/.github/workflows/cleanup-previews.yml
@@ -15,13 +15,14 @@ on:
default: false
type: boolean
-permissions:
- contents: write
- pull-requests: read
+permissions: {}
jobs:
cleanup:
runs-on: ubuntu-latest
+ permissions:
+ contents: write
+ pull-requests: read
steps:
- name: Checkout gh-pages
uses: actions/checkout@v6
diff --git a/.github/workflows/cli-smoke-test.yml b/.github/workflows/cli-smoke-test.yml
index 06f7df35ef..b64e595604 100644
--- a/.github/workflows/cli-smoke-test.yml
+++ b/.github/workflows/cli-smoke-test.yml
@@ -11,8 +11,7 @@ on:
- "apps/docsite/**"
merge_group:
-permissions:
- contents: read
+permissions: {}
concurrency:
group: "cli-smoke-${{ github.event.merge_group.head_sha || github.head_ref }}"
@@ -21,6 +20,8 @@ concurrency:
jobs:
smoke-test:
runs-on: ubuntu-latest
+ permissions:
+ contents: read
steps:
- uses: actions/checkout@v6
diff --git a/.github/workflows/codemod-verify.yml b/.github/workflows/codemod-verify.yml
index ca94ac1a73..3be56ce656 100644
--- a/.github/workflows/codemod-verify.yml
+++ b/.github/workflows/codemod-verify.yml
@@ -19,9 +19,7 @@ on:
paths:
- "packages/cli/src/codemods/**"
-permissions:
- contents: read
- pull-requests: write
+permissions: {}
concurrency:
group: "codemod-verify-${{ github.head_ref }}"
@@ -30,6 +28,9 @@ concurrency:
jobs:
verify-codemods:
runs-on: ubuntu-latest
+ permissions:
+ contents: read
+ pull-requests: write
steps:
- name: Checkout PR
uses: actions/checkout@v6
diff --git a/.github/workflows/codeowner-gate.yml b/.github/workflows/codeowner-gate.yml
index 32a2a1b063..cdec829571 100644
--- a/.github/workflows/codeowner-gate.yml
+++ b/.github/workflows/codeowner-gate.yml
@@ -19,14 +19,15 @@ on:
pull_request_review:
types: [submitted]
-permissions:
- checks: write
- pull-requests: read
- contents: read
+permissions: {}
jobs:
codeowner-gate:
runs-on: ubuntu-latest
+ permissions:
+ checks: write
+ pull-requests: read
+ contents: read
steps:
- name: Checkout CODEOWNERS and DESIGNOWNERS
uses: actions/checkout@v6
diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml
index c1514ca292..4b61fa453d 100644
--- a/.github/workflows/deploy.yml
+++ b/.github/workflows/deploy.yml
@@ -22,10 +22,7 @@ on:
branches: ["main"]
workflow_dispatch:
-permissions:
- contents: write
- pages: write
- id-token: write
+permissions: {}
concurrency:
group: "pages-deploy"
@@ -36,6 +33,8 @@ jobs:
# Fails if exports are stale — run `node scripts/sync-exports.js` locally to fix.
sync-exports:
runs-on: ubuntu-latest
+ permissions:
+ contents: read
steps:
- uses: actions/checkout@v6
@@ -45,6 +44,8 @@ jobs:
test:
runs-on: ubuntu-latest
+ permissions:
+ contents: read
steps:
- uses: actions/checkout@v6
with:
@@ -65,6 +66,8 @@ jobs:
needs: test
if: always() && !cancelled() && needs.test.result == 'success'
runs-on: ubuntu-latest
+ permissions:
+ contents: write
steps:
- name: Checkout
uses: actions/checkout@v6
@@ -258,6 +261,8 @@ jobs:
needs: test
if: always() && !cancelled() && needs.test.result == 'success'
runs-on: ubuntu-latest
+ permissions:
+ contents: read
steps:
- name: Checkout
uses: actions/checkout@v6
@@ -290,6 +295,8 @@ jobs:
needs: test
if: always() && !cancelled() && needs.test.result == 'success'
runs-on: ubuntu-latest
+ permissions:
+ contents: read
steps:
- name: Checkout
uses: actions/checkout@v6
diff --git a/.github/workflows/hardening-issue.yml b/.github/workflows/hardening-issue.yml
index 011d3ee47f..4d97b5465f 100644
--- a/.github/workflows/hardening-issue.yml
+++ b/.github/workflows/hardening-issue.yml
@@ -13,15 +13,16 @@ on:
types: [closed]
branches: [main]
-permissions:
- issues: write
- contents: read
- pull-requests: read
+permissions: {}
jobs:
create-hardening-issues:
if: github.event.pull_request.merged == true
runs-on: ubuntu-latest
+ permissions:
+ issues: write
+ contents: read
+ pull-requests: read
steps:
- name: Detect new components and create hardening issues
uses: actions/github-script@v9
diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml
index d3c61d7277..43b847bf71 100644
--- a/.github/workflows/lint.yml
+++ b/.github/workflows/lint.yml
@@ -8,6 +8,8 @@ on:
pull_request:
branches: [main]
+permissions: {}
+
jobs:
lint:
runs-on: ubuntu-latest
diff --git a/.github/workflows/prune-branches.yml b/.github/workflows/prune-branches.yml
index 6e755403b0..1f7853fa37 100644
--- a/.github/workflows/prune-branches.yml
+++ b/.github/workflows/prune-branches.yml
@@ -9,13 +9,14 @@ on:
- cron: "0 6 * * *" # daily at 6am UTC
workflow_dispatch: # manual trigger
-permissions:
- contents: write
- pull-requests: read
+permissions: {}
jobs:
prune:
runs-on: ubuntu-latest
+ permissions:
+ contents: write
+ pull-requests: read
steps:
- name: Checkout
uses: actions/checkout@v6
diff --git a/.github/workflows/redeploy-preview.yml b/.github/workflows/redeploy-preview.yml
index 1a417e9bf4..39de49c32f 100644
--- a/.github/workflows/redeploy-preview.yml
+++ b/.github/workflows/redeploy-preview.yml
@@ -16,12 +16,7 @@ on:
required: true
type: string
-permissions:
- contents: write
- pages: write
- id-token: write
- pull-requests: read
- actions: read
+permissions: {}
concurrency:
group: "pr-preview-${{ github.event.inputs.pr_number }}"
@@ -30,6 +25,10 @@ concurrency:
jobs:
redeploy-preview:
runs-on: ubuntu-latest
+ permissions:
+ contents: write
+ pull-requests: read
+ actions: read
env:
PR_NUMBER: ${{ github.event.inputs.pr_number }}
diff --git a/.github/workflows/vibe-screenshots.yml b/.github/workflows/vibe-screenshots.yml
index 2df91a39ff..2b67f2e7ee 100644
--- a/.github/workflows/vibe-screenshots.yml
+++ b/.github/workflows/vibe-screenshots.yml
@@ -29,13 +29,14 @@ concurrency:
group: vibe-screenshots-${{ github.run_id }}
cancel-in-progress: false
-permissions:
- contents: write
+permissions: {}
jobs:
build-previews:
name: Build Previews
runs-on: ubuntu-latest
+ permissions:
+ contents: read
steps:
- name: Checkout
uses: actions/checkout@v6
@@ -74,6 +75,8 @@ jobs:
name: Capture Screenshots
needs: build-previews
runs-on: ubuntu-latest
+ permissions:
+ contents: read
steps:
- name: Checkout
uses: actions/checkout@v6
@@ -121,6 +124,8 @@ jobs:
needs: screenshot
if: ${{ github.event.inputs.deploy_to_gh_pages != 'false' }}
runs-on: ubuntu-latest
+ permissions:
+ contents: write
steps:
- name: Checkout gh-pages
uses: actions/checkout@v6