-
Notifications
You must be signed in to change notification settings - Fork 672
117 lines (112 loc) · 3.91 KB
/
ci.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
116
117
name: CI
on: push
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: jwalton/gh-find-current-pr@v1
id: findPr
- uses: actions/setup-node@v3
with:
node-version-file: '.nvmrc'
cache: 'yarn'
- name: Comment on github
run: node ./scripts/github/comment.js "[Preview Preparing...](https://github.com/ng-alain/delon/actions/runs/${{ github.run_id }})"
env:
ACCESS_REPO: ${{ github.repository }}
ACCESS_TOKEN: ${{ secrets.CI_TOKEN }}
PR_NUMBER: ${{ steps.findPr.outputs.pr }}
- uses: actions/cache@v3
with:
path: ./node_modules
key: ${{ runner.os }}-${{ hashFiles('**/yarn.lock', '**/*.patch') }}
- name: Install node modules
run: yarn install --frozen-lockfile
- name: Build artifacts
run: ./scripts/ci/build-artifacts.sh
env:
ACCESS_TOKEN: ${{ secrets.CI_TOKEN }}
- name: Build site
run: yarn run site:build
- name: 'Deploy Site'
run: |
export DEPLOY_DOMAIN=https://preview-${{ steps.findPr.outputs.pr }}-ng-alain-delon.surge.sh
echo "Deploy to $DEPLOY_DOMAIN"
cp ./src/dist/browser/index.html ./src/dist/browser/404.html
npx surge --project ./src/dist/browser --domain $DEPLOY_DOMAIN
env:
ACCESS_REPO: ${{ github.repository }}
ACCESS_TOKEN: ${{ secrets.CI_TOKEN }}
SURGE_LOGIN: ${{ secrets.SURGE_LOGIN }}
SURGE_TOKEN: ${{ secrets.SURGE_TOKEN }}
- name: 'Update comment on github'
run: |
export DEPLOY_DOMAIN=https://preview-${{ steps.findPr.outputs.pr }}-ng-alain-delon.surge.sh
node ./scripts/github/comment.js "[Preview is ready!]($DEPLOY_DOMAIN)"
env:
ACCESS_REPO: ${{ github.repository }}
ACCESS_TOKEN: ${{ secrets.CI_TOKEN }}
PR_NUMBER: ${{ steps.findPr.outputs.pr }}
- name: 'When failed'
if: failure()
run: node ./scripts/github/comment.js "[Preview Build Failed!](https://github.com/ng-alain/delon/actions/runs/${{ github.run_id }})"
env:
ACCESS_REPO: ${{ github.repository }}
ACCESS_TOKEN: ${{ secrets.CI_TOKEN }}
PR_NUMBER: ${{ steps.findPr.outputs.pr }}
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v3
with:
node-version-file: '.nvmrc'
cache: 'yarn'
- uses: actions/cache@v3
with:
path: ./node_modules
key: ${{ runner.os }}-${{ hashFiles('**/yarn.lock', '**/*.patch') }}
- name: Install node modules
run: yarn install --frozen-lockfile
- name: Test
run: yarn run test
- uses: codecov/codecov-action@v3
with:
token: ${{ secrets.CODECOV_TOKEN }}
directory: ./coverage/
files: cobertura-coverage.xml
fail_ci_if_error: true
verbose: true
test-cli:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v3
with:
node-version-file: '.nvmrc'
cache: 'yarn'
- uses: actions/cache@v3
with:
path: ./node_modules
key: ${{ runner.os }}-${{ hashFiles('**/yarn.lock', '**/*.patch') }}
- name: Install node modules
run: yarn install --frozen-lockfile
- name: Test
run: yarn run test:cli
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v3
with:
node-version-file: '.nvmrc'
cache: 'yarn'
- uses: actions/cache@v3
with:
path: ./node_modules
key: ${{ runner.os }}-${{ hashFiles('**/yarn.lock', '**/*.patch') }}
- name: Install node modules
run: yarn install --frozen-lockfile
- name: Check code lint
run: yarn run lint