fix(ci): grant contents: write so the reusable build job can start at all
The first real run of ci.yml was a startup_failure — no jobs, no log, just "this run likely failed because of a workflow file issue". reusable-chrome-extension.yml declares two mutually exclusive jobs: `build` (contents: read, `if: !inputs.release`) and `release` (contents: write, `if: inputs.release`). GitHub validates the caller's grant against EVERY job the reusable declares, before evaluating any `if:` — so passing `release: false` does not exempt the caller from the release job's requirement, and the least-privilege `contents: read` in docs/12 §2.1's sample rejects the whole run. CodeQL succeeded on the same push because its caller happened to grant a superset of what its single job needs, which is what isolated the cause. docs/12 §2.1 updated with the same grant and a warning, since its sample is what this stub was written from. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
674ac341e5
commit
2c8fba9a74
2 files changed
+22
-2
No files matched your search
@@ -50,7 +50,17 @@ jobs:
|
||||
# passing a named secret to it is a workflow-compile error.
|
||||
uses: poli0981/.github/.github/workflows/reusable-chrome-extension.yml@main
|
||||
permissions:
|
||||
contents: read
|
||||
# `contents: write`, not `read`, even though nothing here writes.
|
||||
#
|
||||
# The reusable has two mutually exclusive jobs: `build` (contents: read,
|
||||
# `if: !inputs.release`) and `release` (contents: write, `if:
|
||||
# inputs.release`). GitHub validates the caller's grant against EVERY job
|
||||
# the reusable declares, BEFORE evaluating any `if:` — so passing
|
||||
# `release: false` does not exempt us from the release job's requirement.
|
||||
# Granting only `contents: read` makes the whole run fail at startup with
|
||||
# no jobs and no log, which is how this was found (docs/12 §2.1's sample
|
||||
# had the same too-narrow grant).
|
||||
contents: write
|
||||
with:
|
||||
# All four are required in practice. Leaving package-manager at its
|
||||
# 'none' default skips install and build, then fails on
|
||||
|
||||
+11
-1
@@ -71,7 +71,7 @@ jobs:
|
||||
needs: quality
|
||||
uses: poli0981/.github/.github/workflows/reusable-chrome-extension.yml@main
|
||||
permissions:
|
||||
contents: read
|
||||
contents: write # see the warning below — `read` fails at startup
|
||||
with:
|
||||
package-manager: 'npm' # 01 §6 commits package-lock.json
|
||||
node-version: '24'
|
||||
@@ -84,6 +84,16 @@ All four `with:` values are required. Omitting `package-manager` defaults it to
|
||||
`'none'`, which skips install/build entirely and then fails on
|
||||
`test -f ./manifest.json` — a file WXT never writes to the repo root.
|
||||
|
||||
⚠️ **`contents: write` on the `build` job is not a mistake.** The reusable
|
||||
declares two mutually exclusive jobs — `build` (`contents: read`,
|
||||
`if: !inputs.release`) and `release` (`contents: write`, `if: inputs.release`).
|
||||
GitHub validates the caller's grant against **every job the reusable declares,
|
||||
before evaluating any `if:`**, so `release: false` does not exempt the caller
|
||||
from the release job's requirement. Granting `contents: read` makes the entire
|
||||
run fail with `startup_failure`: no jobs, no log, and only the generic "this run
|
||||
likely failed because of a workflow file issue" in the UI. Verified 2026-07-26
|
||||
on the first real run of this workflow.
|
||||
|
||||
`npm run guard` runs the same script locally and in CI, so the gate cannot
|
||||
drift between the two (`10 §3`). It is the single canonical pattern defined in
|
||||
`08_MV3_COMPLIANCE.md §3`; do not restate the pattern here or anywhere else.
|
||||
|
||||
Reference in new issue
Block a user