-
Notifications
You must be signed in to change notification settings - Fork 0
115 lines (94 loc) · 2.92 KB
/
build.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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
name: build
on:
pull_request:
push:
branches: [ main ]
permissions:
contents: write
jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ ubuntu-latest, macos-latest, windows-latest ]
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: 18
- name: Check package.json is sorted
run: npx sort-package-json --check
- name: Restore npm dependencies cache
id: npm-cache
uses: actions/cache@v3
with:
path: ./node_modules
key: ${{ runner.os }}-npm-cache-${{ hashFiles('package.json') }}-${{ hashFiles('package-lock.json') }}
- name: Install npm dependencies
if: steps.npm-cache.outputs.cache-hit != 'true'
run: npm ci
- name: ESLint analysis
run: npm run eslint
- name: Stylelint analysis
run: npm run stylelint
- name: Build
run: npm run build
- name: Test
run: npm run test
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
with:
flags: unit-tests-${{ matrix.os }}
fail_ci_if_error: true
- name: Upload build artifact
if: github.event_name == 'push' && github.ref == 'refs/heads/main' && matrix.os == 'ubuntu-latest'
uses: actions/upload-artifact@master
with:
name: build
path: ./build
deploy:
needs: build
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Restore npm dependencies cache
id: npm-cache
uses: actions/cache@v3
with:
path: ./node_modules
key: ${{ runner.os }}-npm-cache-${{ hashFiles('package.json') }}-${{ hashFiles('package-lock.json') }}
- name: Install npm dependencies
if: steps.npm-cache.outputs.cache-hit != 'true'
run: npm ci
- name: Download build artifact
uses: actions/download-artifact@master
with:
name: build
path: ./build
- name: Deploy to GitHub Pages
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_branch: gh-pages
publish_dir: ./build
release:
needs: deploy
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Bump version
id: version
uses: paulhatch/[email protected]
- name: Create GitHub tag and release
uses: softprops/[email protected]
with:
tag_name: ${{ steps.version.outputs.version_tag }}
generate_release_notes: true