Skip to content

Commit 6bfc18a

Browse files
SoonIterCopilot
andauthored
chore(ci): harden github actions (#4)
## Summary - Harden GitHub Actions workflows with workflow-level `permissions: {}` and job-scoped token permissions. - Pin all workflow action references to full commit SHAs while keeping version comments for maintainability. - Disable implicit package-manager caching in `actions/setup-node` via `package-manager-cache: false`. ## Validation - `git diff --check` - YAML parsed successfully for `.github/workflows/test.yml` and `.github/workflows/release.yml` - Confirmed no remaining `uses: ...@v*` action references No repository `preflight` script is defined, so targeted workflow checks were used. --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
1 parent 5ba4a8b commit 6bfc18a

2 files changed

Lines changed: 16 additions & 11 deletions

File tree

.github/workflows/release.yml

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,22 +9,24 @@ on:
99

1010
workflow_dispatch:
1111

12-
permissions:
13-
contents: write
14-
id-token: write
12+
permissions: {}
1513

1614
jobs:
1715
publish:
1816
runs-on: ubuntu-latest
1917
environment: npm
18+
permissions:
19+
contents: write
20+
id-token: write
2021
steps:
2122
- name: Checkout
22-
uses: actions/checkout@v5
23+
uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5.0.1
2324

2425
- name: Setup Node.js
25-
uses: actions/setup-node@v4
26+
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
2627
with:
2728
node-version: 22.20.0
29+
package-manager-cache: false
2830

2931
# Update npm to the latest version to enable OIDC
3032
# Use corepack to install pnpm
@@ -39,12 +41,11 @@ jobs:
3941
run: pnpm install
4042

4143
- name: Publish
42-
uses: JS-DevTools/npm-publish@v4
44+
uses: JS-DevTools/npm-publish@0fd2f4369c5d6bcfcde6091a7c527d810b9b5c3f # v4.1.5
4345
with:
44-
# token: empty # unnecessary if you use trusted publishing via OIDC
4546
provenance: true
4647

4748
- name: Create GitHub Release
48-
uses: ncipollo/release-action@v1
49+
uses: ncipollo/release-action@339a81892b84b4eeb0f6e744e4574d79d0d9b8dd # v1.21.0
4950
with:
5051
generateReleaseNotes: "true"

.github/workflows/test.yml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,27 +10,31 @@ on:
1010
# Allows you to run this workflow manually from the Actions tab
1111
workflow_dispatch:
1212

13+
permissions: {}
14+
1315
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
1416
jobs:
1517
test:
1618
runs-on: ${{ matrix.os }}
19+
permissions:
20+
contents: read
1721
strategy:
1822
matrix:
1923
os: [ubuntu-latest, windows-latest]
2024

2125
# Steps represent a sequence of tasks that will be executed as part of the job
2226
steps:
2327
- name: Checkout
24-
uses: actions/checkout@v5
28+
uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5.0.1
2529

2630
- name: Install Pnpm
2731
run: npm i -g corepack@latest --force && corepack enable
2832

2933
- name: Setup Node.js
30-
uses: actions/setup-node@v4
34+
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
3135
with:
3236
node-version: 22.20.0
33-
cache: "pnpm"
37+
package-manager-cache: false
3438

3539
- name: Install Dependencies
3640
run: pnpm install && npx playwright install chromium

0 commit comments

Comments
 (0)