1- # 文件名建议统一为 pull-request.yml
1+ # 文件名建议统一为 pull-request.yml
22# 应用 test-build.yml 的 demo
33
44name : MAIN_PULL_REQUEST
99 types : [opened, synchronize, reopened]
1010
1111jobs :
12- call-test-build :
13- uses : Tencent/tdesign/.github/workflows/test-build.yml@main
12+ check :
13+ runs-on : ubuntu-latest
14+ steps :
15+ - uses : actions/checkout@v4
16+ - name : check_github_primary_email
17+ run : |
18+ log_emails=$(git log --pretty=format:"%ae %ce" -1)
19+ if [[ ${log_emails} =~ 'tdesign@tencent.com' ]];then
20+ echo "$log_emails 跳过验证"
21+ exit 0
22+ fi
23+ if [[ ${log_emails} =~ '@tencent.com' ]];then
24+ echo "默认邮箱 $log_emails 校验非法,可以去 https://github.com/settings/emails 更改"
25+ exit 2;
26+ else
27+ echo "邮箱 $log_emails 校验通过";
28+ fi
29+ - uses : actions/checkout@v4
30+ with :
31+ ref : ${{ github.event.pull_request.head.sha }}
32+ - name : check_local_email
33+ run : |
34+ log_emails=$(git log --pretty=format:"%ae %ce" -1)
35+ if [[ ${log_emails} =~ 'tdesign@tencent.com' ]];then
36+ echo "$log_emails 跳过验证"
37+ exit 0
38+ fi
39+ if [[ ${log_emails} =~ '@tencent.com' ]];then
40+ echo "本地提交邮箱 $log_emails 校验非法,需要本地更改重新提交"
41+ exit 2;
42+ else
43+ echo "邮箱 $log_emails 校验通过";
44+ fi
45+
46+ test :
47+ # needs: check
48+ runs-on : ubuntu-latest
49+ steps :
50+ - uses : actions/checkout@v4
51+ with :
52+ submodules : recursive
53+ - uses : pnpm/action-setup@v4
54+
55+ - uses : actions/setup-node@v4
56+ with :
57+ node-version-file : .node-version
58+
59+ - name : Get pnpm store directory
60+ id : pnpm-cache
61+ run : |
62+ echo "pnpm_cache_dir=$(pnpm store path)" >> $GITHUB_OUTPUT
63+
64+ - uses : actions/cache@v4
65+ with :
66+ # 缓存路径
67+ path : ${{ steps.pnpm-cache.outputs.pnpm_cache_dir }}
68+ # 缓存键
69+ key : ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
70+ # 恢复缓存的备用键
71+ restore-keys : |
72+ ${{ runner.os }}-pnpm-store-
73+
74+ - run : pnpm install
75+ - run : pnpm run lint
76+ - run : pnpm run test
77+ # upload report to codecov
78+ - uses : codecov/codecov-action@v2
79+ with :
80+ token : ${{ secrets.CODECOV_TOKEN }}
81+
82+ site :
83+ runs-on : ubuntu-latest
84+ # needs: test
85+ steps :
86+ - uses : actions/checkout@v4
87+ with :
88+ submodules : recursive
89+
90+ - uses : pnpm/action-setup@v4
91+
92+ - uses : actions/setup-node@v4
93+ with :
94+ node-version-file : .node-version
95+
96+ - name : Get pnpm store directory
97+ id : pnpm-cache
98+ run : |
99+ echo "pnpm_cache_dir=$(pnpm store path)" >> $GITHUB_OUTPUT
100+
101+ - uses : actions/cache@v4
102+ with :
103+ # 缓存路径
104+ path : ${{ steps.pnpm-cache.outputs.pnpm_cache_dir }}
105+ # 缓存键
106+ key : ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
107+ # 恢复缓存的备用键
108+ restore-keys : |
109+ ${{ runner.os }}-pnpm-store-
110+
111+ - run : pnpm install
112+
113+ - name : Build site
114+ run : pnpm site:preview
115+
116+ - run : |
117+ zip -r site.zip packages/tdesign-react/site/dist
118+
119+ - name : upload site artifact
120+ uses : actions/upload-artifact@v4
121+ with :
122+ name : site
123+ path : site.zip
124+ retention-days : 5
125+
126+ - name : Save PR number
127+ if : ${{ always() }}
128+ run : echo ${{ github.event.number }} > ./pr-id.txt
129+
130+ - name : Upload PR number
131+ if : ${{ always() }}
132+ uses : actions/upload-artifact@v4
133+ with :
134+ name : pr
135+ path : ./pr-id.txt
136+
137+ build :
138+ runs-on : ubuntu-latest
139+ # needs: build
140+ steps :
141+ - uses : actions/checkout@v4
142+ with :
143+ submodules : recursive
144+
145+ - uses : pnpm/action-setup@v4
146+
147+ - uses : actions/setup-node@v4
148+ with :
149+ node-version-file : .node-version
150+ - name : Get pnpm store directory
151+ id : pnpm-cache
152+ run : |
153+ echo "pnpm_cache_dir=$(pnpm store path)" >> $GITHUB_OUTPUT
154+
155+ - uses : actions/cache@v4
156+ with :
157+ # 缓存路径
158+ path : ${{ steps.pnpm-cache.outputs.pnpm_cache_dir }}
159+ # 缓存键
160+ key : ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
161+ # 恢复缓存的备用键
162+ restore-keys : |
163+ ${{ runner.os }}-pnpm-store-
164+
165+ - run : pnpm install
166+
167+ - name : Build
168+ run : pnpm run build
0 commit comments