Skip to content

Commit 346d762

Browse files
authored
Merge pull request #2158 from ghinks/docs/actions/guides/building-and-testing-nodejs
docs: update nodejs template guide to match node versions
2 parents 79b9dbc + fea1ea5 commit 346d762

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

content/actions/guides/building-and-testing-nodejs.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,11 @@ To get started quickly, add the template to the `.github/workflows` directory of
3737
```yaml{:copy}
3838
name: Node.js CI
3939
40-
on: [push]
40+
on:
41+
push:
42+
branches: [ $default-branch ]
43+
pull_request:
44+
branches: [ $default-branch ]
4145
4246
jobs:
4347
build:
@@ -46,19 +50,17 @@ jobs:
4650
4751
strategy:
4852
matrix:
49-
node-version: [8.x, 10.x, 12.x]
53+
node-version: [10.x, 12.x, 14.x, 15.x]
5054
5155
steps:
5256
- uses: actions/checkout@v2
5357
- name: Use Node.js ${{ matrix.node-version }}
5458
uses: actions/setup-node@v1
5559
with:
5660
node-version: ${{ matrix.node-version }}
57-
- run: npm install
61+
- run: npm ci
5862
- run: npm run build --if-present
5963
- run: npm test
60-
env:
61-
CI: true
6264
```
6365
{% endraw %}
6466

@@ -70,15 +72,15 @@ The easiest way to specify a Node.js version is by using the `setup-node` action
7072

7173
The `setup-node` action takes a Node.js version as an input and configures that version on the runner. The `setup-node` action finds a specific version of Node.js from the tools cache on each runner and adds the necessary binaries to `PATH`, which persists for the rest of the job. Using the `setup-node` action is the recommended way of using Node.js with {% data variables.product.prodname_actions %} because it ensures consistent behavior across different runners and different versions of Node.js. If you are using a self-hosted runner, you must install Node.js and add it to `PATH`.
7274

73-
The template includes a matrix strategy that builds and tests your code with three Node.js versions: 8.x, 10.x, and 12.x. The 'x' is a wildcard character that matches the latest minor and patch release available for a version. Each version of Node.js specified in the `node-version` array creates a job that runs the same steps.
75+
The template includes a matrix strategy that builds and tests your code with four Node.js versions: 10.x, 12.x, 14.x, and 15.x. The 'x' is a wildcard character that matches the latest minor and patch release available for a version. Each version of Node.js specified in the `node-version` array creates a job that runs the same steps.
7476

7577
Each job can access the value defined in the matrix `node-version` array using the `matrix` context. The `setup-node` action uses the context as the `node-version` input. The `setup-node` action configures each job with a different Node.js version before building and testing code. For more information about matrix strategies and contexts, see "[Workflow syntax for {% data variables.product.prodname_actions %}](/actions/automating-your-workflow-with-github-actions/workflow-syntax-for-github-actions#jobsjob_idstrategymatrix)" and "[Context and expression syntax for {% data variables.product.prodname_actions %}](/actions/reference/context-and-expression-syntax-for-github-actions)."
7678

7779
{% raw %}
7880
```yaml
7981
strategy:
8082
matrix:
81-
node-version: [8.x, 10.x, 12.x]
83+
node-version: [10.x, 12.x, 14.x, 15.x]
8284

8385
steps:
8486
- uses: actions/checkout@v2
@@ -116,11 +118,9 @@ jobs:
116118
uses: actions/setup-node@v1
117119
with:
118120
node-version: '12.x'
119-
- run: npm install
121+
- run: npm ci
120122
- run: npm run build --if-present
121123
- run: npm test
122-
env:
123-
CI: true
124124
```
125125
{% endraw %}
126126

0 commit comments

Comments
 (0)