ci: 添加站点部署预览 #6
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: PREVIEW_BUILD | |
| on: | |
| pull_request: | |
| branches: [main, rss1102/*] | |
| types: [opened, synchronize, reopened] | |
| permissions: | |
| contents: write | |
| pull-requests: write | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| if: > | |
| !contains(github.event.head_commit.message, '[skip ci]') && | |
| !contains(github.event.head_commit.message, '[ci skip]') | |
| steps: | |
| - name: Setup Flutter | |
| uses: subosito/flutter-action@v2 | |
| with: | |
| flutter-version: '3.32.0' | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '20' | |
| - name: Install pnpm | |
| uses: pnpm/action-setup@v4 | |
| with: | |
| version: 9 | |
| - name: Checkout tdesign-flutter-tools | |
| uses: actions/checkout@v4 | |
| - name: Install tools dependencies | |
| run: flutter pub get | |
| - name: Build binary | |
| run: dart compile exe bin/main.dart -o tdesign_flutter_tools | |
| - name: Checkout tdesign-flutter | |
| run: git clone --depth 1 --branch develop https://github.com/Tencent/tdesign-flutter.git | |
| - name: Verify binary | |
| run: dart run .github/scripts/cross_platform_verify.dart tdesign-flutter tdesign_flutter_tools | |
| - name: Create build env | |
| run: | | |
| cat > build-env.txt << EOF | |
| PR_NUMBER=${{ github.event.pull_request.number }} | |
| COMMIT_SHA=${{ github.event.pull_request.head.sha }} | |
| EOF | |
| - name: Upload build env | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: build-env | |
| path: build-env.txt | |
| retention-days: 5 | |
| - name: Build site | |
| working-directory: tdesign-flutter/tdesign-site | |
| run: | | |
| pnpm install --no-frozen-lockfile | |
| npm run site | |
| - name: Prepare web artifact | |
| run: | | |
| mkdir -p tdesign-flutter-web | |
| cp -r tdesign-flutter/tdesign-site/_site/* tdesign-flutter-web/ | |
| # SPA 路由支持 | |
| cp tdesign-flutter-web/index.html tdesign-flutter-web/200.html | |
| cp tdesign-flutter-web/index.html tdesign-flutter-web/404.html | |
| - name: Upload web artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: tdesign-flutter-web | |
| path: tdesign-flutter-web | |
| retention-days: 5 |