From f9255d3eb32a30f7640986d2f077703ff1f07c92 Mon Sep 17 00:00:00 2001 From: Sergio Moya <1083296+smoya@users.noreply.github.com> Date: Tue, 18 Oct 2022 17:57:24 +0200 Subject: [PATCH] feat: install Node v16 when lockfileVersion is 2 --- .github/workflows/if-nodejs-pr-testing.yml | 13 +++++++++ .github/workflows/if-nodejs-release.yml | 30 +++++++++++++++++++- .github/workflows/if-nodejs-version-bump.yml | 13 +++++++++ 3 files changed, 55 insertions(+), 1 deletion(-) diff --git a/.github/workflows/if-nodejs-pr-testing.yml b/.github/workflows/if-nodejs-pr-testing.yml index 1dcccd32..271e5213 100644 --- a/.github/workflows/if-nodejs-pr-testing.yml +++ b/.github/workflows/if-nodejs-pr-testing.yml @@ -34,12 +34,25 @@ jobs: run: test -e ./package.json && echo "::set-output name=exists::true" || echo "::set-output name=exists::false" shell: bash - if: steps.packagejson.outputs.exists == 'true' + name: Check package-lock.json lockfileVersion + id: packagelockjson + shell: bash + run: | + grep '"lockfileVersion": 1' package-lock.json && echo "::set-output name=lockfileVersion::1" || echo "::set-output name=lockfileVersion::2" + - if: steps.packagejson.outputs.exists == 'true' && steps.packagelockjson.outputs.lockfileVersion == 1 name: Setup Node.js uses: actions/setup-node@v2 with: node-version: 14 cache: 'npm' cache-dependency-path: '**/package-lock.json' + - if: steps.packagejson.outputs.exists == 'true' && steps.packagelockjson.outputs.lockfileVersion == 2 + name: Setup Node.js + uses: actions/setup-node@v2 + with: + node-version: 16 + cache: 'npm' + cache-dependency-path: '**/package-lock.json' - if: steps.packagejson.outputs.exists == 'true' name: Install dependencies id: first-installation diff --git a/.github/workflows/if-nodejs-release.yml b/.github/workflows/if-nodejs-release.yml index 948edb89..dde4058e 100644 --- a/.github/workflows/if-nodejs-release.yml +++ b/.github/workflows/if-nodejs-release.yml @@ -36,12 +36,25 @@ jobs: run: test -e ./package.json && echo "::set-output name=exists::true" || echo "::set-output name=exists::false" shell: bash - if: steps.packagejson.outputs.exists == 'true' + name: Check package-lock.json lockfileVersion + id: packagelockjson + shell: bash + run: | + grep '"lockfileVersion": 1' package-lock.json && echo "::set-output name=lockfileVersion::1" || echo "::set-output name=lockfileVersion::2" + - if: steps.packagejson.outputs.exists == 'true' && steps.packagelockjson.outputs.lockfileVersion == 1 name: Setup Node.js uses: actions/setup-node@v2 with: node-version: 14 cache: 'npm' cache-dependency-path: '**/package-lock.json' + - if: steps.packagejson.outputs.exists == 'true' && steps.packagelockjson.outputs.lockfileVersion == 2 + name: Setup Node.js + uses: actions/setup-node@v2 + with: + node-version: 16 + cache: 'npm' + cache-dependency-path: '**/package-lock.json' - if: steps.packagejson.outputs.exists == 'true' name: Install dependencies run: npm install @@ -73,10 +86,25 @@ jobs: id: packagejson run: test -e ./package.json && echo "::set-output name=exists::true" || echo "::set-output name=exists::false" - if: steps.packagejson.outputs.exists == 'true' + name: Check package-lock.json lockfileVersion + id: packagelockjson + shell: bash + run: | + grep '"lockfileVersion": 1' package-lock.json && echo "::set-output name=lockfileVersion::1" || echo "::set-output name=lockfileVersion::2" + - if: steps.packagejson.outputs.exists == 'true' && steps.packagelockjson.outputs.lockfileVersion == 1 name: Setup Node.js - uses: actions/setup-node@v1 + uses: actions/setup-node@v2 with: node-version: 14 + cache: 'npm' + cache-dependency-path: '**/package-lock.json' + - if: steps.packagejson.outputs.exists == 'true' && steps.packagelockjson.outputs.lockfileVersion == 2 + name: Setup Node.js + uses: actions/setup-node@v2 + with: + node-version: 16 + cache: 'npm' + cache-dependency-path: '**/package-lock.json' - if: steps.packagejson.outputs.exists == 'true' name: Install dependencies run: npm install diff --git a/.github/workflows/if-nodejs-version-bump.yml b/.github/workflows/if-nodejs-version-bump.yml index 5e7aa14a..c7b5dff2 100644 --- a/.github/workflows/if-nodejs-version-bump.yml +++ b/.github/workflows/if-nodejs-version-bump.yml @@ -25,12 +25,25 @@ jobs: id: packagejson run: test -e ./package.json && echo "::set-output name=exists::true" || echo "::set-output name=exists::false" - if: steps.packagejson.outputs.exists == 'true' + name: Check package-lock.json lockfileVersion + id: packagelockjson + shell: bash + run: | + grep '"lockfileVersion": 1' package-lock.json && echo "::set-output name=lockfileVersion::1" || echo "::set-output name=lockfileVersion::2" + - if: steps.packagejson.outputs.exists == 'true' && steps.packagelockjson.outputs.lockfileVersion == 1 name: Setup Node.js uses: actions/setup-node@v2 with: node-version: 14 cache: 'npm' cache-dependency-path: '**/package-lock.json' + - if: steps.packagejson.outputs.exists == 'true' && steps.packagelockjson.outputs.lockfileVersion == 2 + name: Setup Node.js + uses: actions/setup-node@v2 + with: + node-version: 16 + cache: 'npm' + cache-dependency-path: '**/package-lock.json' - if: steps.packagejson.outputs.exists == 'true' name: Install dependencies run: npm install