Useful Snippets

Welcome!


This blog is used to collect useful snippets related to Linux, PHP, MySQL and more. Feel free to post comments with improvements or questions!

Are your smart devices spying on you? Make better purchasing choices and find products that respect your privacy at Unwanted.cloud

RSS Latest posts from my personal blog


Most viewed posts


Subscribe to RSS feed


Use nvm in GitHub actions when building a Node.js project

Stanislav KhromovStanislav Khromov

Node Version Managernvm 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.

Web Developer at Aftonbladet (Schibsted Media Group)
Any opinions on this blog are my own and do not reflect the views of my employer.
LinkedIn
Twitter
WordPress.org Profile
Visit my other blog

Comments 0
There are currently no comments.