File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -10,10 +10,16 @@ concurrency:
1010on :
1111 push :
1212 branches :
13- - main # Run on push to main branch only
13+ - main
14+ paths :
15+ - " package.json"
16+ - " package-lock.json"
1417 pull_request :
1518 branches :
16- - " **" # Run on PR to any branch
19+ - " **"
20+ paths :
21+ - " package.json"
22+ - " package-lock.json"
1723
1824jobs :
1925 verify-package-lock :
4753 - name : Setup Node.js
4854 uses : actions/setup-node@v4
4955 with :
50- node-version : ' 16 .x'
56+ node-version : ' 20 .x'
5157
5258 - name : Validate package-lock.json is valid and in sync
5359 run : npm ci --dry-run --ignore-scripts
60+
61+ - name : Check package-lock.json is up to date with package.json
62+ if : github.event_name == 'pull_request'
63+ run : |
64+ # Regenerate the lock file from the current package.json without
65+ # installing node_modules, then check if it differs from what was committed.
66+ cp package-lock.json package-lock.json.bak
67+ npm install --package-lock-only --ignore-scripts
68+
69+ if ! diff -q package-lock.json package-lock.json.bak > /dev/null 2>&1; then
70+ echo "ERROR: package-lock.json is out of date with package.json"
71+ echo "Please run 'npm install' and commit the updated package-lock.json"
72+ exit 1
73+ fi
74+
75+ echo "SUCCESS: package-lock.json is up to date"
You can’t perform that action at this time.
0 commit comments