reboottime / WebDevelopment

Some notes, thoughts and articles aggregated here about UI/UX and web development.
6 stars 0 forks source link

Force nodejs version in github action workflow #182

Open reboottime opened 11 months ago

reboottime commented 11 months ago

Overview

  1. Recap on some basic Github actions commands
  2. Force github action uses you preferred nodejs version
reboottime commented 11 months ago

Recap on Github actions

reboottime commented 11 months ago

Force Github action use specific node version

  1. Setup the nodejs version in your package.json engines property:
  "engines": {
    "node": ">=18.16.0"
  },```

  2. Apply set up node version action

  ```sh
      - name: Get Node.js version
        run: |
          NODE_VERSION=$(jq -r '.engines.node' package.json)
          echo "NODE_VERSION=${NODE_VERSION}" >> $GITHUB_ENV
      - uses: actions/setup-node@v4
        with:
          node-version: ${{ env.NODE_VERSION }}