Skip to content

Instantly share code, notes, and snippets.

@svierk
Last active June 2, 2023 06:26
Show Gist options
  • Save svierk/f341d2d31df75b370b60b10cda4768f4 to your computer and use it in GitHub Desktop.
Save svierk/f341d2d31df75b370b60b10cda4768f4 to your computer and use it in GitHub Desktop.
Sample GitHub Actions template for extracting the node version from the package.json's engine setting
steps:
- name: Get node version from package.json
run: |
echo "$(cat ./package.json)" | jq .engines.node | xargs -I {} echo "nodeVersion="{} >> $GITHUB_ENV
- name: Use node version ${{ env.nodeVersion }} from package.json
uses: actions/setup-node@main
with:
node-version: ${{ env.nodeVersion }}
cache: 'npm'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment