Skip to content

Commit 172b79e

Browse files
committed
Use engines.node as source of version data for "actions/setup-node" action
The "actions/setup-node" GitHub Actions action is used to set up Node.js in the GitHub Actions runner machine. The action supports obtaining the Node.js version to set up from the `engines.node` key of the package.json file. This allows us to define the standardized version of Node.js for use by project contributors in a single place rather than having to maintain multiple instances of that data.
1 parent c807c34 commit 172b79e

File tree

7 files changed

+17
-29
lines changed

7 files changed

+17
-29
lines changed

.github/workflows/check-markdown-task.yml

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
11
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/check-markdown-task.md
22
name: Check Markdown
33

4-
env:
5-
# See: https://github.com/actions/setup-node/#readme
6-
NODE_VERSION: 16.x
7-
84
# See: https://docs.github.com/actions/using-workflows/events-that-trigger-workflows
95
on:
106
create:
@@ -77,7 +73,7 @@ jobs:
7773
- name: Setup Node.js
7874
uses: actions/setup-node@v5
7975
with:
80-
node-version: ${{ env.NODE_VERSION }}
76+
node-version-file: package.json
8177

8278
- name: Initialize markdownlint-cli problem matcher
8379
uses: xt0rted/markdownlint-problem-matcher@v3
@@ -105,7 +101,7 @@ jobs:
105101
- name: Setup Node.js
106102
uses: actions/setup-node@v5
107103
with:
108-
node-version: ${{ env.NODE_VERSION }}
104+
node-version-file: package.json
109105

110106
- name: Install Task
111107
uses: arduino/setup-task@v2

.github/workflows/check-prettier-formatting-task.yml

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
11
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/check-prettier-formatting-task.md
22
name: Check Prettier Formatting
33

4-
env:
5-
# See: https://github.com/actions/setup-node/#readme
6-
NODE_VERSION: 16.x
7-
84
# See: https://docs.github.com/actions/using-workflows/events-that-trigger-workflows
95
on:
106
create:
@@ -242,7 +238,7 @@ jobs:
242238
- name: Setup Node.js
243239
uses: actions/setup-node@v5
244240
with:
245-
node-version: ${{ env.NODE_VERSION }}
241+
node-version-file: package.json
246242

247243
- name: Install Task
248244
uses: arduino/setup-task@v2

.github/workflows/check-taskfiles.yml

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
11
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/check-taskfiles.md
22
name: Check Taskfiles
33

4-
env:
5-
# See: https://github.com/actions/setup-node/#readme
6-
NODE_VERSION: 16.x
7-
84
# See: https://docs.github.com/actions/using-workflows/events-that-trigger-workflows
95
on:
106
create:
@@ -77,7 +73,7 @@ jobs:
7773
- name: Setup Node.js
7874
uses: actions/setup-node@v5
7975
with:
80-
node-version: ${{ env.NODE_VERSION }}
76+
node-version-file: package.json
8177

8278
- name: Download JSON schema for Taskfiles
8379
id: download-schema

.github/workflows/check-workflows-task.yml

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
11
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/check-workflows-task.md
22
name: Check Workflows
33

4-
env:
5-
# See: https://github.com/actions/setup-node/#readme
6-
NODE_VERSION: 16.x
7-
84
# See: https://docs.github.com/actions/using-workflows/events-that-trigger-workflows
95
on:
106
push:
@@ -38,7 +34,7 @@ jobs:
3834
- name: Setup Node.js
3935
uses: actions/setup-node@v5
4036
with:
41-
node-version: ${{ env.NODE_VERSION }}
37+
node-version-file: package.json
4238

4339
- name: Install Task
4440
uses: arduino/setup-task@v2

.github/workflows/sync-labels-npm.yml

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,6 @@
11
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/sync-labels-npm.md
22
name: Sync Labels
33

4-
env:
5-
# See: https://github.com/actions/setup-node/#readme
6-
NODE_VERSION: 16.x
7-
CONFIGURATIONS_FOLDER: .github/label-configuration-files
8-
CONFIGURATIONS_ARTIFACT_PREFIX: label-configuration-file-
9-
104
# See: https://docs.github.com/actions/using-workflows/events-that-trigger-workflows
115
on:
126
push:
@@ -27,6 +21,10 @@ on:
2721
workflow_dispatch:
2822
repository_dispatch:
2923

24+
env:
25+
CONFIGURATIONS_FOLDER: .github/label-configuration-files
26+
CONFIGURATIONS_ARTIFACT_PREFIX: label-configuration-file-
27+
3028
jobs:
3129
check:
3230
runs-on: ubuntu-latest
@@ -40,7 +38,7 @@ jobs:
4038
- name: Setup Node.js
4139
uses: actions/setup-node@v5
4240
with:
43-
node-version: ${{ env.NODE_VERSION }}
41+
node-version-file: package.json
4442

4543
- name: Download JSON schema for labels configuration file
4644
id: download-schema
@@ -138,7 +136,7 @@ jobs:
138136
- name: Setup Node.js
139137
uses: actions/setup-node@v5
140138
with:
141-
node-version: ${{ env.NODE_VERSION }}
139+
node-version-file: package.json
142140

143141
- name: Merge label configuration files
144142
run: |

package-lock.json

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,8 @@
66
"markdown-link-check": "^3.13.7",
77
"markdownlint-cli": "^0.37.0",
88
"prettier": "^3.6.2"
9+
},
10+
"engines": {
11+
"node": "16.x"
912
}
1013
}

0 commit comments

Comments
 (0)