mirror of
https://github.com/ant-design/ant-design.git
synced 2024-12-11 13:59:11 +08:00
926adaf565
* chore: init workflow * fix restore * try more * update ci * update preview * add workflow_run * replace action * update keep day * use cross action * surge it * add failed step * fix trigger tree * update patch number * fix patch * messager * target * add warning * use artifact * test outputs * fix checker * Update index.en-US.md * clean up Co-authored-by: xrkffgg <xrkffgg@gmail.com>
84 lines
2.1 KiB
YAML
84 lines
2.1 KiB
YAML
# Each PR will build preview site that help to check code is work as expect.
|
|
|
|
name: Preview Build
|
|
|
|
on: pull_request
|
|
|
|
jobs:
|
|
# Prepare node modules. Reuse cache if available
|
|
setup:
|
|
name: prepare preview
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: checkout
|
|
uses: actions/checkout@master
|
|
|
|
- name: cache package-lock.json
|
|
uses: actions/cache@v2
|
|
with:
|
|
path: package-temp-dir
|
|
key: lock-${{ github.sha }}
|
|
|
|
- name: create package-lock.json
|
|
run: npm i --package-lock-only
|
|
|
|
- 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
|
|
uses: actions/cache@v2
|
|
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-site:
|
|
name: build preview
|
|
runs-on: ubuntu-latest
|
|
needs: setup
|
|
steps:
|
|
- name: checkout
|
|
uses: actions/checkout@master
|
|
|
|
- name: restore cache from package-lock.json
|
|
uses: actions/cache@v2
|
|
with:
|
|
path: package-temp-dir
|
|
key: lock-${{ github.sha }}
|
|
|
|
- name: restore cache from node_modules
|
|
uses: actions/cache@v2
|
|
with:
|
|
path: node_modules
|
|
key: node_modules-${{ hashFiles('**/package-temp-dir/package-lock.json') }}
|
|
|
|
- name: npm run site
|
|
id: site
|
|
run: npm run site
|
|
|
|
- name: upload site artifact
|
|
uses: actions/upload-artifact@v2
|
|
with:
|
|
name: site
|
|
path: _site/
|
|
retention-days: 5
|
|
|
|
# Upload PR id for next workflow use
|
|
- name: Save PR number
|
|
if: ${{ always() }}
|
|
run: echo ${{ github.event.number }} > ./pr-id.txt
|
|
|
|
- name: Upload PR number
|
|
if: ${{ always() }}
|
|
uses: actions/upload-artifact@v2
|
|
with:
|
|
name: pr
|
|
path: ./pr-id.txt
|