-
Notifications
You must be signed in to change notification settings - Fork 0
53 lines (44 loc) · 1.45 KB
/
main.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
41
42
43
44
45
46
47
48
49
50
51
52
53
name: CI
on:
push:
branches: [master]
pull_request:
branches: [master]
env:
# Setting an environment variable with the value of a configuration variable
CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
PACKAGE_NAME: 'unknown'
HAVE_COVERAGE_SCRIPT: false
PACKAGE_VERSION: 'unknown'
NPM_VERSION: 'unknown'
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: '18.x'
registry-url: 'https://registry.npmjs.org'
- name: Read package information
run: |
echo "PACKAGE_NAME=$(cat package.json | jq -r .name)" >> $GITHUB_ENV
echo "PACKAGE_VERSION=$(cat package.json | jq -r .version)" >> $GITHUB_ENV
echo "HAVE_COVERAGE_SCRIPT=$(jq 'if .scripts.coverage == null then false else true end' package.json)" >> $GITHUB_ENV
- name: Install dependencies
run: npm i
- name: Run unit tests
run: npm test
- name: Run linter checks
run: npm run lint
- name: Run and publish code coverage
if: |
github.ref == 'refs/heads/main' &&
env.CC_TEST_REPORTER_ID != '' &&
env.HAVE_COVERAGE_SCRIPT == 'true'
uses: paambaati/[email protected]
env:
CC_TEST_REPORTER_ID: ${{ env.CC_TEST_REPORTER_ID }}
with:
coverageCommand: npm run coverage