-
Notifications
You must be signed in to change notification settings - Fork 631
136 lines (112 loc) · 3.5 KB
/
deploy-site-preview.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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
name: deploy-site-preview
on:
pull_request:
types: [opened, synchronize, reopened]
push:
tags:
- '*'
- '!(*(beta|alpha)*)'
workflow_dispatch:
jobs:
build-site:
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@master
- name: setup node
uses: actions/setup-node@v3
with:
node-version: 16
cache: 'yarn'
- name: install
run: yarn && cd site && yarn && cd ../
- name: build components
run: yarn icon && yarn build:es && yarn build:css
- name: build site
run: yarn build:site
- name: Upload site-dist Artifact
uses: actions/upload-artifact@v3.1.1
with:
name: site-dist
path: site/dist
deploy-preview:
runs-on: ubuntu-latest
needs: build-site
steps:
- name: checkout
uses: actions/checkout@master
- name: setup node
uses: actions/setup-node@v3
with:
node-version: 18
cache: 'yarn'
- name: Download site-dist Artifact
uses: actions/download-artifact@v3.0.1
with:
# Artifact name
name: site-dist
# Destination path
path: dist/
- name: netlify install
run: yarn add netlify-cli@16 -D
- name: get PreviewID
run: |
if ${{ github.event_name == 'pull_request' }}; then
echo "PreviewID=${{ github.event.number }}" >> $GITHUB_ENV
else
echo "PreviewID=main" >> $GITHUB_ENV
fi
- name: netlify deploy
env:
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }}
run: netlify deploy --auth $NETLIFY_AUTH_TOKEN --site $NETLIFY_SITE_ID --dir=dist --alias=pr-preview-${{ env.PreviewID }}
add-pr-comment:
runs-on: ubuntu-latest
needs: deploy-preview
if: github.event_name == 'pull_request'
steps:
- name: checkout
uses: actions/checkout@master
- name: setup node
uses: actions/setup-node@v3
with:
node-version: 16
cache: 'yarn'
- name: PR Comment
uses: mshick/add-pr-comment@v2
env:
PR_NUMBER: ${{ github.event.number }}
with:
# Message to comment
message: |
[📚 📚 Site Preview: https://pr-preview-${{ env.PR_NUMBER }}--arco-design.netlify.app](https://pr-preview-${{ env.PR_NUMBER }}--arco-design.netlify.app/react/docs/start)
image-test:
runs-on: ubuntu-latest
needs: deploy-preview
steps:
- name: checkout
uses: actions/checkout@v3
with:
fetch-depth: 2
- name: install
run: yarn
- name: setup node
uses: actions/setup-node@v3
with:
node-version: 16
cache: 'yarn'
- name: build:cjs
run: yarn icon && yarn build:cjs
- name: get PreviewID
run: |
if ${{ github.event_name == 'pull_request' }}; then
echo "PreviewID=${{ github.event.number }}" >> $GITHUB_ENV
else
echo "PreviewID=main" >> $GITHUB_ENV
fi
- name: gen screenshots
run: yarn run test:screenshots --domain=https://pr-preview-${{ env.PreviewID }}--arco-design.netlify.app
- name: upload screenshots to argos-cli
# run: npx @argos-ci/cli upload ./tests/__screenshots__
run: yarn add @argos-ci/cli -D && yarn run argos upload ./tests/__screenshots__