GitHub Action
Update Node.js versions
A GitHub Action to automatically update you repository to the latest Node.js
versions. Supports updating GitHub workflows and package.json engines
.
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), thepeter-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 defaultsecrets.GITHUB_TOKEN
does not have the required permissions.
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.
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 anode-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 theengines
field in yourpackage.json
file. It will use the lowest Node version as the minimal supported version.{ "engines": { "node": ">=14" } }
name | default | description |
---|---|---|
versions |
latest |
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
name | description |
---|---|
versions |
The Node versions to update to as stringified JSON array (e.g. "[14, 16, 18]" ) |