-
-
Notifications
You must be signed in to change notification settings - Fork 19
92 lines (78 loc) · 2.86 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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
name: CI Build
on:
# Trigger the workflow on push or pull request,
# but only for the master branch on Push and any branches on PR
push:
branches:
- master
- next
pull_request:
branches:
- '**'
jobs:
run:
name: Node ${{ matrix.node }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
node: [18]
steps:
- name: Clone repository
uses: actions/checkout@v4
with:
fetch-depth: 3
- name: Set Node.js version
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node }}
- run: node --version
- run: npm --version
- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "dir=$(yarn cache dir)" >> $GITHUB_OUTPUT
- uses: actions/cache@v3
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- name: Run yarn install dependencies
run: yarn --frozen-lockfile
- name: Run Jest unit tests
run: yarn test:ci
- name: Upload Jest coverage to Codecov
if: ${{ !contains(github.event.head_commit.message, format('chore{0} release', ':')) }}
uses: codecov/codecov-action@v3
with:
token: ${{ secrets.CODECOV_TOKEN }}
directory: test/jest-coverage
verbose: true
- name: Prod Build for GitHub demo website (required for Cypress)
run: yarn build:demo
- name: Start HTTP Server
run: yarn serve:demo &
- name: Run Cypress E2E tests
uses: cypress-io/github-action@59810ebfa5a5ac6fcfdcfdf036d1cd4d083a88f2 # v6.5.0
with:
working-directory: test/cypress
config-file: cypress.config.ts
wait-on: 'http://localhost:9000'
browser: chrome
record: true
env:
# pass the Dashboard record key as an environment variable
CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }}
# pass GitHub token to allow accurately detecting a build vs a re-run build
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# deploy (re-publish) GitHub demo page with a Prod build but only when merging to "master" branch
# and the commit message contains the text "chore: release"
- name: Deploy to gh-pages
if: |
github.ref == 'refs/heads/master' &&
contains(github.event.head_commit.message, format('chore{0} release', ':')) || contains(github.event.head_commit.message, '[update github demo]')
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./docs