-
Notifications
You must be signed in to change notification settings - Fork 0
109 lines (86 loc) · 2.51 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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
name: Deploy
on:
push:
branches: [main]
jobs:
build:
name: Build and test on Node ${{ matrix.node }} and ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
node: ['16.x']
os: [ubuntu-latest, windows-latest, macOS-latest]
steps:
- name: Checkout repo
uses: actions/checkout@v2
- name: Use Node ${{ matrix.node }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node }}
- name: Install deps and build (with cache)
uses: bahmutov/npm-install@v1
- name: Test
run: yarn test --ci --coverage --maxWorkers=2
- name: Build
run: yarn build
publish:
name: Publish to NPM registry on main branch changes
runs-on: ubuntu-latest
needs: build
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node }}
- name: Set NPM_TOKEN
run: npm config set //registry.npmjs.org/:_authToken ${NPM_TOKEN}
- name: Set package version to ENV
run: |
PV=$(cat package.json \
| grep version \
| head -1 \
| awk -F: '{ print $2 }' \
| sed 's/[",]//g')
NLV=$(npm view sla_work_time version)
echo "PACKAGE_VERSION=$PV" >> $GITHUB_ENV
echo "NPM_LATEST_VERSION=$NLV" >> $GITHUB_ENV
- name: Install
run: |
if [ ${{ env.PACKAGE_VERSION }} != ${{ env.NPM_LATEST_VERSION }} ]; then
yarn install
else
echo "No new deployments, skipping install"
fi
- name: Publish
run: |
if [ ${{ env.PACKAGE_VERSION }} != ${{ env.NPM_LATEST_VERSION }} ]; then
npm publish
else
echo "No new deployments, skipping deploy"
fi
deploy_demo_ui:
defaults:
run:
working-directory: demo
runs-on: ubuntu-latest
needs: publish
strategy:
matrix:
node: ['16.x']
steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node-version }}
- name: Build the package
run: |
yarn
yarn build
- name: deploy to gh-pages
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./demo/dist