-
Notifications
You must be signed in to change notification settings - Fork 124
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e08f5c4
commit 5ba6769
Showing
1 changed file
with
56 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
name: lockfile check for Node v20 | ||
|
||
|
||
on: | ||
workflow_call: | ||
|
||
|
||
jobs: | ||
version-check: | ||
runs-on: ubuntu-20.04 | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
|
||
|
||
- name: Retrieve lockfile version | ||
id: getversion | ||
run: | | ||
echo "VERSION=$(cat package-lock.json | grep '\"lockfileVersion\": 3,')" >> $GITHUB_ENV | ||
- name: Check lockfile version | ||
if: ${{ env.VERSION == null }} | ||
run: | | ||
echo "ERROR: Outdated package-lock file. Use NPM10 to install dependencies." | ||
exit 1 | ||
- name: Check NPM version | ||
run: | | ||
npm_version=$(npm -v) | ||
if [[ ! "$npm_version" =~ ^10 ]]; then | ||
echo "ERROR: NPM version 10 is required. Current version: $npm_version" | ||
exit 1 | ||
fi | ||
mismatch-check: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Check out the repo | ||
uses: actions/checkout@v4 | ||
|
||
|
||
- name: Install Node.js | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: 20 | ||
|
||
|
||
- name: Check sync | ||
run: | | ||
problems=$(npm ls --all --package-lock-only --json | jq '.problems[]?' -r) | ||
if [[ -n "$problems" ]]; then | ||
echo "$problems" | ||
echo | ||
echo "Mismatch between package.json and package-lock.json. Please regenerate package lock file with 'npm install'." | ||
exit 1 | ||
fi |