1212 required : true
1313 type : string
1414
15+ # Workflow-level permissions use least privilege (read-only).
16+ # Jobs that need elevated permissions (npm OIDC, GHCR push) declare them
17+ # individually on the job — see publish-npm and publish-docker.
1518permissions :
1619 contents : read
17- packages : write
18- id-token : write # Required for npm trusted publishing (OIDC)
1920
2021env :
2122 REGISTRY : ghcr.io
@@ -115,6 +116,11 @@ jobs:
115116 publish-npm :
116117 name : Publish to npmjs.org
117118 needs : [build-native]
119+ # id-token: write is required for npm OIDC trusted publishing;
120+ # contents: read for checkout. Scoped to this job only (least privilege).
121+ permissions :
122+ contents : read
123+ id-token : write
118124 runs-on : [self-hosted, Linux, X64, "1ES.Pool=hld-kvm-amd","JobId=hyperagent-publish-npm-${{ github.run_id }}-${{ github.run_number }}-${{ github.run_attempt }}"]
119125 steps :
120126 - uses : actions/checkout@v6
@@ -124,9 +130,10 @@ jobs:
124130 node-version : " 22"
125131 registry-url : " https://registry.npmjs.org"
126132
127- # Trusted publishing requires npm >=11.5.1 for OIDC token exchange
133+ # Trusted publishing requires npm >=11.5.1 for OIDC token exchange.
134+ # Pin to ^11.5.1 so we don't silently get an older 11.x that lacks OIDC.
128135 - name : Upgrade npm for trusted publishing
129- run : npm install -g npm@11 && npm --version
136+ run : npm install -g npm@^11.5.1 && npm --version
130137
131138 - uses : hyperlight-dev/ci-setup-workflow@v1.9.0
132139 with :
@@ -176,6 +183,11 @@ jobs:
176183 publish-docker :
177184 name : Publish to GitHub Container Registry
178185 needs : [build-native]
186+ # packages: write for pushing the image to GHCR.
187+ # Scoped to this job only (least privilege).
188+ permissions :
189+ contents : read
190+ packages : write
179191 runs-on : ubuntu-latest
180192 steps :
181193 - uses : actions/checkout@v6
0 commit comments