上传字体文件 #1452
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: Build and Deploy to EdgeOne | |
| # 向主干分支推送代码时触发部署 | |
| on: | |
| push: | |
| branches: | |
| - astro-pure-v4_0_3 | |
| workflow_dispatch: # 允许手动触发 | |
| jobs: | |
| build-and-deploy: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Setup Bun | |
| uses: oven-sh/setup-bun@v1 | |
| with: | |
| bun-version: latest | |
| - name: Setup Python (for font subsetting) | |
| uses: actions/setup-python@v4 | |
| with: | |
| python-version: '3.x' | |
| - name: Install fonttools | |
| run: pip install fonttools brotli | |
| - name: Download font file | |
| run: | | |
| mkdir -p fonts-source | |
| echo "📥 下载思源宋体字体文件..." | |
| # 从 GitHub 直接下载 Noto Serif SC Regular TTF | |
| curl -L "https://github.com/google/fonts/raw/main/ofl/notoserifsc/NotoSerifSC-Regular.ttf" \ | |
| -o fonts-source/NotoSerifSC-Regular.ttf || { | |
| echo "❌ 字体文件下载失败" | |
| exit 1 | |
| } | |
| ls -lh fonts-source/ | |
| echo "✅ 字体文件下载完成" | |
| - name: Install dependencies | |
| run: bun install | |
| # edgeone CLI 已包含在 devDependencies 中 | |
| - name: Build project | |
| run: bun run build | |
| - name: Generate font subset (post-build script) | |
| run: node scripts/subset-fonts.js | |
| # 如果字体子集化失败,会终止整个流程(已移除 continue-on-error) | |
| - name: Verify build output | |
| run: | | |
| echo "📦 Build output directory contents:" | |
| ls -lh dist/ | head -20 | |
| echo "" | |
| echo "🔤 Font files:" | |
| ls -lh public/fonts/ 2>/dev/null || echo "No font files found" | |
| - name: Deploy to EdgeOne Pages | |
| run: bunx edgeone pages deploy dist -n ${{ secrets.EDGEONE_PROJECT_NAME }} -t ${{ secrets.EDGEONE_API_TOKEN }} | |
| env: | |
| EDGEONE_API_TOKEN: ${{ secrets.EDGEONE_API_TOKEN }} | |
| EDGEONE_PROJECT_NAME: ${{ secrets.EDGEONE_PROJECT_NAME }} |