fix bug and update #188
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 GitHub Pages | |
| on: | |
| push: | |
| branches: [ main, master ] # Adjust branches as needed | |
| pull_request: | |
| branches: [ main, master ] # Adjust branches as needed | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.ref }} | |
| cancel-in-progress: true | |
| permissions: | |
| contents: write # 需要写入权限来部署到 GitHub Pages | |
| pages: write # 专门的 Pages 部署权限 | |
| id-token: write # OIDC 认证所需的权限 | |
| jobs: | |
| check: | |
| strategy: | |
| matrix: | |
| node: [ 22, 23 ] | |
| runs-on: ubuntu-latest | |
| name: Astro Check for Node.js ${{ matrix.node }} | |
| steps: | |
| - name: Setup Node.js | |
| uses: actions/setup-node@cdca7365b2dadb8aad0a33bc7601856ffabcc48e # v4.3.0 | |
| with: | |
| node-version: ${{ matrix.node }} # Use LTS | |
| - name: Checkout | |
| uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | |
| - name: Setup pnpm | |
| uses: pnpm/action-setup@a7487c7e89a18df4991f7f222e4898a00d66ddda # v4.1.0 | |
| with: | |
| run_install: false # Disable auto-install | |
| - name: Install dependencies | |
| run: pnpm install --frozen-lockfile | |
| - name: Run Astro Check | |
| run: pnpm astro check | |
| build: | |
| strategy: | |
| matrix: | |
| node: [ 23 ] | |
| if: ${{ github.event_name == 'push' && contains(' refs/heads/main refs/heads/master ', github.ref) }} | |
| needs: check # 确保检查通过后再部署 | |
| runs-on: ubuntu-latest | |
| name: Deploy Astro Site to GitHub Pages | |
| steps: | |
| - name: Setup Node.js | |
| uses: actions/setup-node@cdca7365b2dadb8aad0a33bc7601856ffabcc48e # v4.3.0 | |
| with: | |
| node-version: ${{ matrix.node }} | |
| - name: Checkout | |
| uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | |
| - name: Setup pnpm | |
| uses: pnpm/action-setup@a7487c7e89a18df4991f7f222e4898a00d66ddda # v4.1.0 | |
| with: | |
| run_install: false # Disable auto-install | |
| - name: Install dependencies | |
| run: pnpm install --frozen-lockfile | |
| # 构建生产版本 | |
| - name: Build Astro site | |
| run: | | |
| echo "PUBLIC_URL='https://${{ github.repository_owner }}.github.io/aLinChee_Blog'" >> .env | |
| echo "BASE_PATH='/aLinChee_Blog'" >> .env | |
| pnpm run build | |
| # 部署到 GitHub Pages | |
| - name: Setup Pages | |
| uses: actions/configure-pages@v4 | |
| with: | |
| enablement: true | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Upload artifact | |
| uses: actions/upload-pages-artifact@v3 | |
| with: | |
| path: './dist' # 匹配 Astro 默认输出目录 | |
| - name: Deploy to GitHub Pages | |
| id: deployment | |
| uses: actions/deploy-pages@v4 |