Node Version Manager – nvm
comes preinstalled on most of the Ubuntu images GitHub provides, including ubuntu-latest
. (See here for more details). You don’t need any additional actions to use it.
Here is a very basic configuration that will invoke nvm
and build your project with the correct Node version. Note that you have to have a .nvmrc
file in your project root for this to work.
name: Build and Deploy
on:
push:
branches:
- master
jobs:
build:
name: Build
runs-on: ubuntu-latest
steps:
- name: Checkout Repo
uses: actions/checkout@master
- name: Set the correct Node version using nvm
shell: bash -l {0}
run: nvm install
- name: Install Dependencies
run: npm install
- name: Build
run: npm run build
# Here you would add your other steps, such as deploying the code, building an artifact, etc.