Installs the dependencies of a Node.js project with Yarn and runs package scripts, e.g. lint and build.
name: CI
on: [ push, pull_request ]
permissions:
contents: read
jobs:
build:
uses: MyCoRe-Org/github-workflows/.github/workflows/node-build.yml@v1
with:
node-version: '24'| Input | Required | Default | Description |
|---|---|---|---|
node-version |
yes | Node.js version, e.g. '24' |
|
scripts |
no | lint build |
Space-separated package scripts to run |
The workflow needs no secrets.
node-setupchecks out the repository without keeping the token and sets up Node.js.- Corepack is enabled, so the Yarn version from the
packageManagerfield ofpackage.jsonis used. Node.js 25 and newer no longer ship Corepack, it is installed with npm then. node_modulesis restored from the cache, keyed by runner OS and architecture, Node.js version andyarn.lock. Projects with Yarn Plug'n'Play have nonode_modules, the cache stays empty for them.yarn installruns with a frozen lockfile,--frozen-lockfilefor Yarn 1 and--immutablefor newer versions. Ayarn.lockthat does not matchpackage.jsonfails the build.- Every script in
scriptsruns withyarn run, in a log group of its own.
A project without a build script:
with:
node-version: '24'
scripts: lint test-publish