You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: content/actions/guides/building-and-testing-nodejs.md
+10-10Lines changed: 10 additions & 10 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -37,7 +37,11 @@ To get started quickly, add the template to the `.github/workflows` directory of
37
37
```yaml{:copy}
38
38
name: Node.js CI
39
39
40
-
on: [push]
40
+
on:
41
+
push:
42
+
branches: [ $default-branch ]
43
+
pull_request:
44
+
branches: [ $default-branch ]
41
45
42
46
jobs:
43
47
build:
@@ -46,19 +50,17 @@ jobs:
46
50
47
51
strategy:
48
52
matrix:
49
-
node-version: [8.x, 10.x, 12.x]
53
+
node-version: [10.x, 12.x, 14.x, 15.x]
50
54
51
55
steps:
52
56
- uses: actions/checkout@v2
53
57
- name: Use Node.js ${{ matrix.node-version }}
54
58
uses: actions/setup-node@v1
55
59
with:
56
60
node-version: ${{ matrix.node-version }}
57
-
- run: npm install
61
+
- run: npm ci
58
62
- run: npm run build --if-present
59
63
- run: npm test
60
-
env:
61
-
CI: true
62
64
```
63
65
{% endraw %}
64
66
@@ -70,15 +72,15 @@ The easiest way to specify a Node.js version is by using the `setup-node` action
70
72
71
73
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`.
72
74
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.
74
76
75
77
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)."
0 commit comments