Skip to content

Commit

Permalink
feat: support preview
Browse files Browse the repository at this point in the history
  • Loading branch information
uyarn committed Apr 7, 2024
1 parent 79418ba commit 5f4e3c7
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 28 deletions.
36 changes: 8 additions & 28 deletions .github/workflows/preview-site.yml
Original file line number Diff line number Diff line change
@@ -1,30 +1,10 @@
# 文件名建议统一为 preview-publish
# 应用 preview.yml 的 demo
name: preview site
on: [pull_request]
name: MAIN_PULL_REQUEST

on:
pull_request:
branches: [main]
types: [opened, synchronize, reopened]

jobs:
build-site:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: 18
- uses: actions/cache@v2
env:
cache-name: cache-nodemodules
with:
path: ~/.npm
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package.json') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-
${{ runner.os }}-
- run: pnpm install
- name: build-site
run: pnpm run site:preview
call-preview:
uses: Tencent/tdesign/.github/workflows/preview.yml@main
secrets:
TDESIGN_SURGE_TOKEN: ${{ secrets.TDESIGN_SURGE_TOKEN }}
call-test-build:
uses: Tencent/tdesign/.github/workflows/test-build-site.yml@main
51 changes: 51 additions & 0 deletions .github/workflows/test-build-site.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: TEST_AND_BUILD

on:
workflow_call:

jobs:
site:
runs-on: ubuntu-latest
# needs: test
steps:
- uses: pnpm/action-setup@v3
with:
version: 8
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: 18
- uses: actions/cache@v2
env:
cache-name: cache-nodemodules
with:
path: ~/.npm
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package.json') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-
${{ runner.os }}-
- run: pnpm install
- name: Build site
run: npm run site:preview

- run: |
zip -r _site.zip _site
- name: upload _site artifact
uses: actions/upload-artifact@v2
with:
name: _site
path: _site.zip
retention-days: 5

- 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

0 comments on commit 5f4e3c7

Please sign in to comment.