Merge pull request #9 from caoergou/feature/readme-and-build-optimiza… #91
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: Deploy to GitHub Pages | |
| on: | |
| push: | |
| branches: [main] | |
| workflow_dispatch: | |
| permissions: | |
| contents: read | |
| pages: write | |
| id-token: write | |
| concurrency: | |
| group: pages | |
| cancel-in-progress: true | |
| jobs: | |
| deploy: | |
| runs-on: ubuntu-latest | |
| environment: | |
| name: github-pages | |
| url: ${{ steps.deployment.outputs.page_url }} | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '20' | |
| cache: 'npm' | |
| - name: Install dependencies | |
| run: npm ci | |
| - name: Install Playwright browsers | |
| run: npx playwright install chromium | |
| - name: Build app and generate all assets | |
| run: npm run build:all | |
| - name: Generate sitemap and robots.txt | |
| run: | | |
| chmod +x scripts/generate-sitemap.sh | |
| # 使用站点正式域名,与 index.html / blog 中的 canonical 一致 | |
| BASE_URL="https://eric.run.place/MermZen" | |
| ./scripts/generate-sitemap.sh "$BASE_URL" | |
| - name: Copy static content into dist | |
| run: | | |
| # 预览图片(合并进 dist/assets/,与 Vite 打包产物共存) | |
| [ -d assets ] && cp assets/* dist/assets/ 2>/dev/null || true | |
| # 博客文章 | |
| [ -d blog ] && cp -r blog dist/blog 2>/dev/null || true | |
| # sitemap | |
| [ -f sitemap.xml ] && cp sitemap.xml dist/ || true | |
| - name: Setup Pages | |
| uses: actions/configure-pages@v4 | |
| - name: Upload artifact | |
| uses: actions/upload-pages-artifact@v3 | |
| with: | |
| path: 'dist' | |
| - name: Deploy | |
| id: deployment | |
| uses: actions/deploy-pages@v4 |