2023-10-17 14:05:00 +08:00
|
|
|
# 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:
|
|
|
|
build-site:
|
|
|
|
name: build preview
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
2024-08-18 00:23:19 +08:00
|
|
|
- uses: actions/checkout@v4
|
|
|
|
- uses: oven-sh/setup-bun@v2
|
|
|
|
- run: bun install
|
|
|
|
- name: bun run site
|
2023-10-17 14:05:00 +08:00
|
|
|
id: site
|
2024-08-18 00:23:19 +08:00
|
|
|
run: bun run site
|
2023-10-17 14:05:00 +08:00
|
|
|
env:
|
2024-09-19 03:30:19 +08:00
|
|
|
NODE_OPTIONS: --max_old_space_size=4096
|
2024-08-18 00:23:19 +08:00
|
|
|
- name: run e2e test
|
|
|
|
run: bun run test:site
|
2023-10-17 14:05:00 +08:00
|
|
|
- name: upload site artifact
|
2024-02-02 22:38:36 +08:00
|
|
|
uses: actions/upload-artifact@v4
|
2023-10-17 14:05:00 +08:00
|
|
|
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() }}
|
2024-02-02 22:38:36 +08:00
|
|
|
uses: actions/upload-artifact@v4
|
2023-10-17 14:05:00 +08:00
|
|
|
with:
|
|
|
|
name: pr
|
|
|
|
path: ./pr-id.txt
|