mirror of
https://github.com/ant-design/ant-design.git
synced 2024-12-25 08:43:57 +08:00
1da53ec53d
* chore(deps): bump actions/upload-artifact from 3 to 4 Bumps [actions/upload-artifact](https://github.com/actions/upload-artifact) from 3 to 4. - [Release notes](https://github.com/actions/upload-artifact/releases) - [Commits](https://github.com/actions/upload-artifact/compare/v3...v4) --- updated-dependencies: - dependency-name: actions/upload-artifact dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <support@github.com> * Update preview-build.yml Signed-off-by: lijianan <574980606@qq.com> * Update test.yml Signed-off-by: lijianan <574980606@qq.com> * test: fix Unable to upload to same artifact name from multiple jobs https://github.com/actions/upload-artifact/issues/478#issuecomment-1885470013 --------- Signed-off-by: dependabot[bot] <support@github.com> Signed-off-by: lijianan <574980606@qq.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: lijianan <574980606@qq.com> Co-authored-by: afc163 <afc163@gmail.com>
126 lines
3.2 KiB
YAML
126 lines
3.2 KiB
YAML
# Each PR will build preview site that help to check code is work as expect.
|
|
|
|
name: Preview Build
|
|
|
|
on:
|
|
pull_request:
|
|
types: [opened, synchronize, reopened]
|
|
|
|
# Cancel prev CI if new commit come
|
|
concurrency:
|
|
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
|
|
cancel-in-progress: true
|
|
|
|
permissions:
|
|
contents: read
|
|
|
|
jobs:
|
|
# Prepare node modules. Reuse cache if available
|
|
setup:
|
|
name: prepare preview
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: checkout
|
|
uses: actions/checkout@v4
|
|
|
|
- name: cache package-lock.json
|
|
uses: actions/cache@v4
|
|
with:
|
|
path: package-temp-dir
|
|
key: lock-${{ github.sha }}
|
|
|
|
- name: create package-lock.json
|
|
run: npm i --package-lock-only --ignore-scripts
|
|
|
|
- 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@v4
|
|
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@v4
|
|
|
|
- name: restore cache from package-lock.json
|
|
uses: actions/cache@v4
|
|
with:
|
|
path: package-temp-dir
|
|
key: lock-${{ github.sha }}
|
|
|
|
- name: restore cache from node_modules
|
|
uses: actions/cache@v4
|
|
with:
|
|
path: node_modules
|
|
key: node_modules-${{ hashFiles('**/package-temp-dir/package-lock.json') }}
|
|
|
|
- name: npm run site
|
|
id: site
|
|
run: npm run site
|
|
env:
|
|
SITE_ENV: development
|
|
NODE_OPTIONS: "--max_old_space_size=4096"
|
|
|
|
- name: upload site artifact
|
|
uses: actions/upload-artifact@v4
|
|
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@v4
|
|
with:
|
|
name: pr
|
|
path: ./pr-id.txt
|
|
|
|
site-test:
|
|
name: site E2E test
|
|
runs-on: ubuntu-latest
|
|
needs: [setup, build-site]
|
|
steps:
|
|
- name: checkout
|
|
uses: actions/checkout@v4
|
|
|
|
- name: restore cache from package-lock.json
|
|
uses: actions/cache@v4
|
|
with:
|
|
path: package-temp-dir
|
|
key: lock-${{ github.sha }}
|
|
|
|
- name: restore cache from node_modules
|
|
uses: actions/cache@v4
|
|
with:
|
|
path: node_modules
|
|
key: node_modules-${{ hashFiles('**/package-temp-dir/package-lock.json') }}
|
|
|
|
- name: download site artifact
|
|
uses: actions/download-artifact@v4
|
|
with:
|
|
name: site
|
|
path: _site
|
|
|
|
- name: run e2e test
|
|
run: npm run site:test
|