Skip to content

Commit

Permalink
feat: support reading node version from engines
Browse files Browse the repository at this point in the history
  • Loading branch information
simenandre committed Aug 3, 2023
1 parent 1cd584d commit 35ae68a
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
13 changes: 13 additions & 0 deletions .github/workflows/pnpm-typical.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,20 @@ jobs:

- uses: pnpm/action-setup@v2

- name: Read Node.js version from package.json 📦️
if: ${{ github.event.inputs.node-version == 'use-engines' }}
run: echo ::set-output name=nodeVersion::$(node -p "require('./package.json').engines.node")
id: engines

- name: Use Node LTS ✨
if: ${{ github.event.inputs.node-version == 'use-engines' }}
uses: actions/setup-node@v3
with:
node-version: ${{ steps.engines.outputs.nodeVersion }}
cache: pnpm

- name: Use Node ${{ github.event.inputs.node-version }}} ✨
if: ${{ github.event.inputs.node-version != 'use-engines' }}
uses: actions/setup-node@v3
with:
node-version: ${{ github.event.inputs.node-version }}}
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,6 @@ jobs:
uses: bjerkio/workflows/.github/workflows/pnpm-typical.yml@v1
```
You can set `node-version` to `use-engines` to use `"engines"` from `package.json`.

See [pnpm-typical.yml](.github/workflows/pnpm-typical.yml) for more details.

0 comments on commit 35ae68a

Please sign in to comment.