File tree Expand file tree Collapse file tree 1 file changed +53
-0
lines changed
Expand file tree Collapse file tree 1 file changed +53
-0
lines changed Original file line number Diff line number Diff line change 1+ name : Check Package Lock File
2+
3+ permissions :
4+ contents : read
5+
6+ concurrency :
7+ group : check-package-lock-${{ github.ref }}
8+ cancel-in-progress : true
9+
10+ on :
11+ push :
12+ branches :
13+ - main # Run on push to main branch only
14+ pull_request :
15+ branches :
16+ - " **" # Run on PR to any branch
17+
18+ jobs :
19+ verify-package-lock :
20+ name : Verify package-lock.json exists
21+ runs-on : ubuntu-latest
22+ timeout-minutes : 5
23+
24+ steps :
25+ - name : Checkout repository
26+ uses : actions/checkout@v4
27+
28+ - name : Check if package-lock.json exists
29+ run : |
30+ if [ ! -f "package-lock.json" ]; then
31+ echo "ERROR: package-lock.json file is missing from the repository"
32+ echo "This file is required to ensure consistent dependency versions across all environments"
33+ echo "Please ensure package-lock.json is committed with your changes"
34+ exit 1
35+ fi
36+ echo "SUCCESS: package-lock.json file is present"
37+
38+ - name : Verify package-lock.json is not empty
39+ run : |
40+ if [ ! -s "package-lock.json" ]; then
41+ echo "ERROR: package-lock.json file exists but is empty"
42+ echo "Please run 'npm install' to regenerate the lock file"
43+ exit 1
44+ fi
45+ echo "SUCCESS: package-lock.json file is valid and not empty"
46+
47+ - name : Setup Node.js
48+ uses : actions/setup-node@v4
49+ with :
50+ node-version : ' 16.x'
51+
52+ - name : Validate package-lock.json is valid and in sync
53+ run : npm ci --dry-run --ignore-scripts
You can’t perform that action at this time.
0 commit comments