Bump astro from 5.13.7 to 5.16.11 #30
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: Build Astro dist file | |
| on: | |
| push: | |
| branches: [main] # 推送到 main 分支时触发 | |
| pull_request: | |
| branches: [main] # 拉取请求时也触发(可选) | |
| schedule: | |
| - cron: "0 5 * * *" | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| # 仅新增:声明工作流权限,解决GITHUB_TOKEN无写入权限的核心问题 | |
| permissions: | |
| contents: write | |
| steps: | |
| - name: Install pnpm | |
| uses: pnpm/action-setup@v2 | |
| with: | |
| version: latest # 安装最新版本的 pnpm | |
| - name: Cache pnpm dependencies | |
| uses: actions/cache@v3 | |
| with: | |
| path: ~/.pnpm-store | |
| key: ${{ runner.os }}-pnpm-${{ hashFiles('**/pnpm-lock.yaml') }} | |
| restore-keys: | | |
| ${{ runner.os }}-pnpm- | |
| # 1. 拉取代码 | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| # 仅新增:拉取完整仓库历史,避免推送分支时的历史缺失问题 | |
| with: | |
| fetch-depth: 0 | |
| # 2. 安装 Node.js(Astro 要求 Node.js 18+) | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: 20 # 推荐 20.x | |
| # 3. 安装依赖(解决权限问题的关键步骤) | |
| - name: Install dependencies | |
| run: pnpm install --no-frozen-lockfile | |
| # 若使用 pnpm/yarn,替换为 pnpm install 或 yarn install | |
| # 4. 构建项目,生成 dist 目录 | |
| - name: Build Astro site | |
| run: pnpm run build # 等价于 astro build,输出到 dist | |
| # 5. 推送到 page 分支 | |
| - name: Deploy to page branch | |
| uses: peaceiris/actions-gh-pages@v4 # 第三方 Action,简化推送流程 | |
| with: | |
| github_token: ${{ secrets.GITHUB_TOKEN }} # 自动生成的临时令牌,有仓库操作权限 | |
| publish_dir: ./dist # 要推送的目录(Astro 构建产物) | |
| publish_branch: page # 目标分支(page 分支) | |
| force_orphan: true # 强制创建孤儿分支(只保留 dist 内容,可选) |