-
Notifications
You must be signed in to change notification settings - Fork 70
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ci: node pipelines now setup node version depending on `lockfileVersi…
…on` (#230)
- Loading branch information
Showing
4 changed files
with
59 additions
and
4 deletions.
There are no files selected for viewing
37 changes: 37 additions & 0 deletions
37
.github/actions/get-node-version-from-package-lock/action.yml
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,37 @@ | ||
name: 'Specify Node version based on package-lock file version' | ||
outputs: | ||
version: | ||
description: 'Node.js version number to use with actions/setup-node action' | ||
value: ${{ steps.getnode.outputs.version }} | ||
runs: | ||
using: "composite" | ||
steps: | ||
- name: Get Node version | ||
uses: actions/github-script@v6 | ||
id: getnode | ||
with: | ||
script: | | ||
const { resolve } = require('path'); | ||
const packageLockLocation = './package-lock.json'; | ||
core.info(`Location of the packae-lock verification script is: ${ resolve(packageLockLocation) }`) | ||
const packageLock = require(packageLockLocation); | ||
const packageLockVersion = packageLock.lockfileVersion; | ||
let nodeVersion; | ||
switch (packageLockVersion) { | ||
case 1: | ||
nodeVersion = '14' | ||
break; | ||
case 2: | ||
nodeVersion = '16' | ||
break; | ||
case 3: | ||
nodeVersion = '18' | ||
break; | ||
default: | ||
nodeVersion = '16' | ||
break; | ||
} | ||
core.setOutput('version', nodeVersion); |
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
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
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