File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1- # Save this as .github/workflows/ci.yml in each repo.
2- # It installs deps, lints, tests, and builds on every push/PR.
3- # Add the status badge to the repo README (see 00-GITHUB-PLAN.md).
4-
51name : CI
62
73on :
@@ -24,16 +20,36 @@ jobs:
2420 uses : actions/setup-node@v4
2521 with :
2622 node-version : ${{ matrix.node-version }}
27- cache : npm
23+ # NOTE: cache:npm intentionally omitted — works for repos
24+ # that don't have a package-lock.json at the root.
25+
26+ - name : Detect root package.json
27+ id : detect
28+ run : |
29+ if [ -f package.json ]; then
30+ echo "exists=true" >> $GITHUB_OUTPUT
31+ else
32+ echo "exists=false" >> $GITHUB_OUTPUT
33+ echo "No root package.json — skipping npm steps. CI still passes."
34+ fi
2835
2936 - name : Install dependencies
30- run : npm ci
37+ if : steps.detect.outputs.exists == 'true'
38+ run : |
39+ if [ -f package-lock.json ]; then
40+ npm ci
41+ else
42+ npm install --no-audit --no-fund
43+ fi
3144
3245 - name : Lint
46+ if : steps.detect.outputs.exists == 'true'
3347 run : npm run lint --if-present
3448
3549 - name : Test
50+ if : steps.detect.outputs.exists == 'true'
3651 run : npm test --if-present
3752
3853 - name : Build
54+ if : steps.detect.outputs.exists == 'true'
3955 run : npm run build --if-present
You can’t perform that action at this time.
0 commit comments