Created
September 27, 2019 08:54
-
-
Save tinovyatkin/a4fbcc623cb8cb271c45d48ad8ec45a0 to your computer and use it in GitHub Desktop.
Install Node.JS version pinned at `engines` in `package.json` on GitHub Actions Workflow
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
on: | |
push: | |
branches: | |
- master | |
jobs: | |
test: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v1 | |
# extract `engines.node` from package.json and save it to output | |
- name: Get Node.JS version from package.json | |
id: get-versions | |
run: echo ::set-output name=node::$(jq -r .engines.node ./package.json) | |
- uses: actions/setup-node@v1 | |
with: | |
node-version: ${{steps.get-versions.outputs.node}} |
@karthikeyan-arumugam-1558 is correct, simply specify node-version-file: 'package.json'
under the with:
for the Setup Node action to accomplish the above.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
There's a built-in way - https://github.com/actions/setup-node/blob/main/docs/advanced-usage.md#node-version-file