-
Notifications
You must be signed in to change notification settings - Fork 377
40 lines (33 loc) · 921 Bytes
/
ci.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
name: Node.js CI/CD
on:
pull_request:
branches: [ "*" ]
jobs:
build:
runs-on: ubuntu-latest
outputs:
test-result: ${{ steps.test.outcome }}
steps:
- uses: actions/checkout@v3
- name: Use Node.js 20.x # Updated for Node 20
uses: actions/setup-node@v3
with:
node-version: 20.x
- name: Install dependencies
run: npm ci
- name: Run tests
id: test
run: npm test
check-tests:
needs: build # Depends on the 'build' job
runs-on: ubuntu-latest
if: ${{ always() }}
steps:
- uses: actions/github-script@v6
with:
script: |
if (needs.build.outputs.test-result !== '0') {
core.setFailed('Tests failed - ' + needs.build.outputs.test-result + '. Please fix errors before merging.');
}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}