-
Notifications
You must be signed in to change notification settings - Fork 0
46 lines (44 loc) · 1.32 KB
/
node.js.yml
File metadata and controls
46 lines (44 loc) · 1.32 KB
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
41
42
43
44
45
46
name: Node.js CI
on:
push:
branches: [master]
pull_request:
branches: [master]
jobs:
build:
runs-on: ubuntu-latest
strategy:
fail-fast: true
matrix:
node-version: [20.x]
steps:
- uses: actions/checkout@v4
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
- run: npm install
- run: npm run build --if-present
- run: npm run test --if-present
- name: Get Coverage for badge
run: |
SUMMARY="$(npm run test:ci | tail -2 | head -1)"
TOKENS=($SUMMARY)
echo "COVERAGE=$(echo ${TOKENS[2]})" >> $GITHUB_ENV
REF=${{ github.ref }}
echo "github.ref: $REF"
IFS='/' read -ra PATHS <<< "$REF"
BRANCH_NAME="${PATHS[1]}_${PATHS[2]}"
echo $BRANCH_NAME
echo "BRANCH=$(echo ${BRANCH_NAME})" >> $GITHUB_ENV
- name: Create the Badge
uses: Schneegans/dynamic-badges-action@v1.7.0
with:
auth: ${{ secrets.GIST_SECRET }}
gistID: 729d10e4a538f1645804675d91033f14
filename: dynamic-badges-action.json
label: Test Coverage
message: ${{ env.COVERAGE }}
color: green
logoColor: white
namedLogo: vitest