From ec6b9cee075483ba7e5882f209ae32610288c535 Mon Sep 17 00:00:00 2001 From: coolxitech Date: Mon, 15 Dec 2025 21:47:08 +0800 Subject: [PATCH] =?UTF-8?q?chore(pages):=20=E6=9B=B4=E6=96=B0=20GitHub=20P?= =?UTF-8?q?ages=20=E9=83=A8=E7=BD=B2=E5=B7=A5=E4=BD=9C=E6=B5=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 添加 permissions 配置以支持 GitHub Pages 部署 - 使用 actions/setup-node 安装 Node.js 环境 - 添加缓存配置以加速依赖安装 - 使用 actions/configure-pages 跳过 Jekyll 处理 - 使用 actions/upload-pages-artifact 上传构建产物 - 使用 actions/deploy-pages 部署到 GitHub Pages - 更新构建命令以确保正确执行 - 修改路径配置以匹配项目结构 --- .github/workflows/github-pages.yml | 42 +++++++++++++++++++++--------- 1 file changed, 30 insertions(+), 12 deletions(-) diff --git a/.github/workflows/github-pages.yml b/.github/workflows/github-pages.yml index 79f8c6f..b66721e 100644 --- a/.github/workflows/github-pages.yml +++ b/.github/workflows/github-pages.yml @@ -1,23 +1,41 @@ -name: 部署到GitHub Pages +name: Deploy Vue Project on: push: - branches: [ main ] + branches: [ main ] # 如果你的主分支叫 master,请改为 master + +permissions: + contents: read + pages: write + id-token: write jobs: build-and-deploy: runs-on: ubuntu-latest steps: - - name: 代码检出 + - name: 检出代码 uses: actions/checkout@v6 - - name: 构建前端页面 - run: | - npm install -g pnpm && pnpm install - pnpm run build - - - name: 推送到 Github - uses: JamesIves/github-pages-deploy-action@v4 + - name: 安装 Nodejs + uses: actions/setup-node@v6 with: - folder: docs - branch: gh-pages \ No newline at end of file + node-version: 20 # 建议使用 LTS 版本 + cache: 'npm' + + - name: 安装 pnpm + run: npm install -g pnpm && pnpm install + + - name: 构建前端项目 + run: pnpm install && pnpm run build + + # 关键步骤:告诉 GitHub Actions 跳过 Jekyll 检查 + - name: 配置 Github Pages + uses: actions/configure-pages@v5 + + - name: 上传构建版 + uses: actions/upload-pages-artifact@v4 + with: + path: './docs' + + - name: 部署到 GitHub Pages + uses: actions/deploy-pages@v4 \ No newline at end of file