Skip to content
You're viewing an older version of this GitHub Action. Do you want to see the latest version instead?
arrow-up

GitHub Action

Update Node.js versions

v2.0.0

Update Node.js versions

arrow-up

Update Node.js versions

Update you repository to the latest Node.js versions. Supports updating GitHub workflows and package.json engines

Installation

Copy and paste the following snippet into your .yml file.

              

- name: Update Node.js versions

uses: hongaar/update-node-versions@v2.0.0

Learn more about this action in hongaar/update-node-versions

Choose a version

update-node-versions GitHub tag (latest SemVer)

A GitHub Action to automatically update you repository to the latest Node.js versions. Supports updating GitHub workflows and package.json engines.

Table of contents

Usage

This example workflow will check for new Node versions every Sunday at 7:30 AM. If a new version is found, versions are updated, the changes will be automatically committed to a new branch and a pull request created.

# .github/workflows/update-node-versions.yml
name: update-node-versions

on:
  schedule:
    - cron: "30 7 * * 0"

jobs:
  update-node-versions:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      - uses: hongaar/update-node-versions@v1
      - uses: peter-evans/create-pull-request@v4
        with:
          title: "feat: update node.js versions"
          body: |
            Automated changes by [update-node-versions](https://github.com/hongaar/pdate-node-versions) GitHub action

            BREAKING CHANGE: This updates the supported node.js versions
          token: ${{ secrets.GH_PAT }}

Note: If you're using updaters.workflows (enabled by default), the peter-evans/create-pull-request action needs a Personal Access Token with write access to 'pull requests' and 'workflows' (fine-grained tokens) or 'repo'/'public_repo' and 'workflow' scopes (classic token). The default secrets.GITHUB_TOKEN does not have the required permissions.

Versions

By default, versions will be updated to reflect the 'current' and 'LTS' versions of Node which are not end-of-life.

Optionally, you can configure the action to use another strategy for selecting Node versions.

Updaters

You can configure which parts of your repository are updated. By default, all updaters are enabled. These updaters are available:

  • GitHub workflows
    This will scan all your GitHub workflows for a node-version variable in a matrix strategy and update them accordingly. The name of the variable can be configured.
    strategy:
      matrix:
        node-version: [14, 16, 18]
  • package.json
    This will update the engines field in your package.json file. It will use the lowest Node version as the minimal supported version.
    {
      "engines": {
        "node": ">=14"
      }
    }

Inputs

name default description
versions
latest
lts
lts/-1
lts/-2
Node versions to select, should be resolvable by node-version-alias. Specify each version on a new line.
versions.filter-eol true Filter out Node versions which are end-of-life. Source used for filtering.
updaters.workflows true Update GitHub workflows.
updaters.workflows.variable "node-version" Use this name as the matrix strategy variable to update the Node versions in.
updaters.engines true Update package.json engines.

All inputs are optional. Example:

- uses: hongaar/update-node-versions@v1
  with:
    versions: |
      current
      lts
      lts/-1
      lts/-2
    versions.filter-eol: true
    updaters.workflows: true
    updaters.workflows.variable: node
    updaters.engines: false

Outputs

name description
versions The Node versions to update to as stringified JSON array (e.g. "[14, 16, 18]")