2022-12-09 17:19:40 +08:00
|
|
|
# When pushing a tag. this workflow will trigger site deployment and fixed version address comments
|
2021-02-19 20:35:43 +08:00
|
|
|
|
|
|
|
name: Deploy website
|
|
|
|
on:
|
2022-12-09 17:19:40 +08:00
|
|
|
push:
|
|
|
|
tags:
|
|
|
|
- '5.*'
|
|
|
|
workflow_dispatch:
|
2021-02-19 20:35:43 +08:00
|
|
|
|
2022-04-11 11:15:26 +08:00
|
|
|
permissions:
|
2022-11-20 01:13:54 +08:00
|
|
|
contents: write
|
2022-04-11 11:15:26 +08:00
|
|
|
|
2021-02-19 20:35:43 +08:00
|
|
|
jobs:
|
|
|
|
setup:
|
|
|
|
runs-on: ubuntu-latest
|
2023-04-27 09:42:20 +08:00
|
|
|
if: (startsWith(github.ref, 'refs/tags/') && (contains(github.ref_name, '-') == false)) || github.event_name == 'workflow_dispatch'
|
2021-02-19 20:35:43 +08:00
|
|
|
steps:
|
|
|
|
- name: checkout
|
2023-09-05 11:55:52 +08:00
|
|
|
uses: actions/checkout@v4
|
2021-02-19 20:35:43 +08:00
|
|
|
|
|
|
|
- name: cache package-lock.json
|
2022-03-22 10:59:37 +08:00
|
|
|
uses: actions/cache@v3
|
2021-02-19 20:35:43 +08:00
|
|
|
with:
|
|
|
|
path: package-temp-dir
|
|
|
|
key: lock-${{ github.sha }}
|
|
|
|
|
|
|
|
- name: create package-lock.json
|
2022-06-10 17:06:07 +08:00
|
|
|
run: npm i --package-lock-only --ignore-scripts
|
2021-02-19 20:35:43 +08:00
|
|
|
|
|
|
|
- name: hack for single file
|
|
|
|
run: |
|
|
|
|
if [ ! -d "package-temp-dir" ]; then
|
|
|
|
mkdir package-temp-dir
|
|
|
|
fi
|
|
|
|
cp package-lock.json package-temp-dir
|
|
|
|
- name: cache node_modules
|
|
|
|
id: node_modules_cache_id
|
2022-03-22 10:59:37 +08:00
|
|
|
uses: actions/cache@v3
|
2021-02-19 20:35:43 +08:00
|
|
|
with:
|
|
|
|
path: node_modules
|
|
|
|
key: node_modules-${{ hashFiles('**/package-temp-dir/package-lock.json') }}
|
|
|
|
|
|
|
|
- name: install
|
|
|
|
if: steps.node_modules_cache_id.outputs.cache-hit != 'true'
|
|
|
|
run: npm ci
|
|
|
|
|
|
|
|
build-and-deploy:
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
needs: setup
|
|
|
|
steps:
|
|
|
|
- name: checkout
|
2023-09-05 11:55:52 +08:00
|
|
|
uses: actions/checkout@v4
|
2021-02-19 20:35:43 +08:00
|
|
|
|
2023-05-23 15:58:43 +08:00
|
|
|
- uses: actions/setup-node@v3
|
|
|
|
with:
|
2023-09-13 22:46:23 +08:00
|
|
|
node-version: 18
|
2023-05-23 15:58:43 +08:00
|
|
|
|
2021-02-19 20:35:43 +08:00
|
|
|
- name: restore cache from package-lock.json
|
2022-03-22 10:59:37 +08:00
|
|
|
uses: actions/cache@v3
|
2021-02-19 20:35:43 +08:00
|
|
|
with:
|
|
|
|
path: package-temp-dir
|
|
|
|
key: lock-${{ github.sha }}
|
|
|
|
|
|
|
|
- name: restore cache from node_modules
|
2022-03-22 10:59:37 +08:00
|
|
|
uses: actions/cache@v3
|
2021-02-19 20:35:43 +08:00
|
|
|
with:
|
|
|
|
path: node_modules
|
|
|
|
key: node_modules-${{ hashFiles('**/package-temp-dir/package-lock.json') }}
|
|
|
|
|
2023-05-10 15:14:45 +08:00
|
|
|
- name: build site
|
2021-02-19 20:35:43 +08:00
|
|
|
run: npm run predeploy
|
2023-06-13 12:55:09 +08:00
|
|
|
env:
|
2023-11-23 20:15:12 +08:00
|
|
|
NODE_OPTIONS: "--max_old_space_size=4096"
|
2021-02-19 20:35:43 +08:00
|
|
|
|
2023-05-10 15:14:45 +08:00
|
|
|
- name: build dist and bundle analyzer report
|
|
|
|
run: npm run dist
|
2023-05-15 20:48:55 +08:00
|
|
|
env:
|
2023-05-31 10:16:19 +08:00
|
|
|
ANALYZER: 1
|
2023-11-23 20:15:12 +08:00
|
|
|
NODE_OPTIONS: "--max_old_space_size=4096"
|
2023-05-10 15:14:45 +08:00
|
|
|
|
2022-12-07 17:44:00 +08:00
|
|
|
- name: Get version
|
|
|
|
id: publish-version
|
|
|
|
run: echo "VERSION=$(echo ${{ github.ref_name }} | sed 's/\./-/g')" >> $GITHUB_OUTPUT
|
|
|
|
|
|
|
|
- name: Deploy to GitHub Pages
|
2021-10-19 19:40:08 +08:00
|
|
|
uses: peaceiris/actions-gh-pages@v3
|
2021-02-19 20:35:43 +08:00
|
|
|
with:
|
2022-11-20 01:13:54 +08:00
|
|
|
github_token: ${{ secrets.GITHUB_TOKEN }}
|
2021-11-27 22:51:11 +08:00
|
|
|
publish_dir: ./_site
|
2022-11-19 19:40:53 +08:00
|
|
|
force_orphan: true
|
2022-12-07 17:44:00 +08:00
|
|
|
|
2023-06-20 09:41:03 +08:00
|
|
|
# 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@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'
|
|
|
|
|
2022-12-07 17:44:00 +08:00
|
|
|
- name: Deploy to Surge (with TAG)
|
|
|
|
run: |
|
|
|
|
export DEPLOY_DOMAIN=ant-design-${{ steps.publish-version.outputs.VERSION }}.surge.sh
|
2023-05-10 15:14:45 +08:00
|
|
|
cp report.html ./_site
|
2022-12-07 17:44:00 +08:00
|
|
|
npx surge --project ./_site --domain $DEPLOY_DOMAIN --token ${{ secrets.SURGE_TOKEN }}
|
|
|
|
|
|
|
|
- name: Create Commit Comment
|
2023-09-25 13:45:02 +08:00
|
|
|
uses: peter-evans/commit-comment@v3
|
2022-12-07 17:44:00 +08:00
|
|
|
with:
|
|
|
|
body: |
|
2023-05-10 15:14:45 +08:00
|
|
|
- Documentation site for this release: https://ant-design-${{ steps.publish-version.outputs.VERSION }}.surge.sh
|
|
|
|
- Webpack bundle analyzer report page: https://ant-design-${{ steps.publish-version.outputs.VERSION }}.surge.sh/report.html
|
|
|
|
|