Skip to content
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 24 additions & 2 deletions .github/workflows/check-package-lock.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,16 @@ concurrency:
on:
push:
branches:
- main # Run on push to main branch only
- main
paths:
- "package.json"
- "package-lock.json"
pull_request:
branches:
- "**" # Run on PR to any branch
- "**"
paths:
- "package.json"
- "package-lock.json"

jobs:
verify-package-lock:
Expand Down Expand Up @@ -51,3 +57,19 @@ jobs:

- name: Validate package-lock.json is valid and in sync
run: npm ci --dry-run --ignore-scripts

- name: Check package-lock.json is up to date with package.json
if: github.event_name == 'pull_request'
run: |
# Regenerate the lock file from the current package.json without
# installing node_modules, then check if it differs from what was committed.
cp package-lock.json package-lock.json.bak
npm install --package-lock-only --ignore-scripts

if ! diff -q package-lock.json package-lock.json.bak > /dev/null 2>&1; then
echo "ERROR: package-lock.json is out of date with package.json"
echo "Please run 'npm install' and commit the updated package-lock.json"
exit 1
fi

echo "SUCCESS: package-lock.json is up to date"