forked from ant-design/ant-design
-
Notifications
You must be signed in to change notification settings - Fork 0
129 lines (108 loc) · 4.37 KB
/
site-deploy.yml
File metadata and controls
129 lines (108 loc) · 4.37 KB
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
# When pushing a tag. this workflow will trigger site deployment and fixed version address comments
name: Deploy website
on:
push:
tags:
- '6.*'
workflow_dispatch:
permissions:
contents: write
jobs:
build-site:
runs-on: ubuntu-latest
if: (startsWith(github.ref, 'refs/tags/') && (contains(github.ref_name, '-') == false)) || github.event_name == 'workflow_dispatch'
# https://docs.github.com/en/actions/writing-workflows/workflow-syntax-for-github-actions#example-defining-outputs-for-a-job
outputs:
formatted_version: ${{ steps.shared-formatted_version.outputs.VERSION }}
steps:
- name: checkout
uses: actions/checkout@v6
- uses: utooland/setup-utoo@3a51006d0b66afcc32d1b9177a4b200b74f4a8cb # v1
- run: ut
- name: build site
run: ut predeploy
env:
NODE_OPTIONS: --max_old_space_size=4096
- name: build dist and bundle analyzer report
run: ut dist
env:
ANALYZER: 1
NODE_OPTIONS: --max_old_space_size=4096
- name: move report.html to _site
run: |
if [ -f report.html ]; then
mv report.html _site && echo "report.html moved to _site"
fi
- name: upload site artifact
uses: actions/upload-artifact@v4
with:
name: real-site
path: _site/
retention-days: 1 # Not need to keep for too long
- name: Format version
if: ${{ always() }}
id: shared-formatted_version
run: echo "VERSION=$(echo ${REF_NAME} | sed 's/\./-/g')" >> $GITHUB_OUTPUT
env:
REF_NAME: ${{ github.ref_name }}
deploy-to-pages:
runs-on: blacksmith-4vcpu-ubuntu-2404
needs: build-site
steps:
- uses: utooland/setup-utoo@3a51006d0b66afcc32d1b9177a4b200b74f4a8cb # v1
- name: download site artifact
uses: actions/download-artifact@v8
with:
name: real-site
path: _site
- name: Deploy to GitHub Pages
uses: peaceiris/actions-gh-pages@4f9cc6602d3f66b9c108549d475ec49e8ef4d45e # v4
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./_site
exclude_assets: ./_site/report.html
force_orphan: true
# Since force_orphan will not trigger Sync to Gitee, we need to force run it here
- name: Sync to Gitee
uses: wearerequired/git-mirror-action@c44c68aebe42de49a80a8dfd557416b6a0cafdad # v1
env:
SSH_PRIVATE_KEY: ${{ secrets.GITEE_SSH_PRIVATE_KEY }}
with:
source-repo: 'git@github.com:ant-design/ant-design.git'
destination-repo: 'git@gitee.com:ant-design/ant-design.git'
- name: Deploy to Surge (with TAG)
if: ${{ needs.build-site.outputs.formatted_version != 'master' }}
run: |
export DEPLOY_DOMAIN=ant-design-${{ needs.build-site.outputs.formatted_version }}.surge.sh
utx surge --project ./_site --domain $DEPLOY_DOMAIN --token ${SURGE_TOKEN}
env:
SURGE_TOKEN: ${{ secrets.SURGE_TOKEN }}
- name: Create Commit Comment
if: ${{ needs.build-site.outputs.formatted_version != 'master' }}
uses: peter-evans/commit-comment@f6d60c65d05bb59f750fa51ad3de1d443ba0eb52 # v4
with:
body: |
- Documentation site for this release: https://ant-design-${{ needs.build-site.outputs.formatted_version }}.surge.sh
- Webpack bundle analyzer report page: https://ant-design-${{ needs.build-site.outputs.formatted_version }}.surge.sh/report.html
# https://github.com/ant-design/ant-design/pull/49213/files#r1625446496
upload-to-release:
runs-on: blacksmith-4vcpu-ubuntu-2404
# 仅在 tag 的时候工作,因为我们要将内容发布到以 tag 为版本号的 release 里
if: startsWith(github.ref, 'refs/tags/')
needs: build-site
steps:
- name: download site artifact
uses: actions/download-artifact@v8
with:
name: real-site
path: _site
- name: Tarball site
run: |
cd ./_site
tar -czf ../website.tar.gz --transform 's|^|antd-${{ needs.build-site.outputs.formatted_version }}-website/|' .
cd ..
- name: Upload to Release
uses: softprops/action-gh-release@b4309332981a82ec1c5618f44dd2e27cc8bfbfda # v3.0.0
with:
fail_on_unmatched_files: true
files: website.tar.gz