From 8f30361972c38ce851923f14f21cfebdd07e812d Mon Sep 17 00:00:00 2001 From: GeWuYou <95328647+GeWuYou@users.noreply.github.com> Date: Wed, 11 Feb 2026 12:42:55 +0800 Subject: [PATCH] =?UTF-8?q?refactor(docs):=20=E5=B0=86=E6=96=87=E6=A1=A3?= =?UTF-8?q?=E6=9E=84=E5=BB=BA=E5=B7=A5=E5=85=B7=E4=BB=8E=20DocFX=20?= =?UTF-8?q?=E8=BF=81=E7=A7=BB=E5=88=B0=20VitePress?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 移除 .NET SDK 相关配置,改为使用 Node.js 环境 - 更新依赖安装方式,使用 npm 替代 dotnet restore - 修改构建命令为 npm run build,替换原有的 DocFX 构建流程 - 调整输出路径配置,从 docfx/_site 改为 docs/.vitepress/dist - 更新工作流触发条件,启用 push 触发器替代手动触发 - 重命名作业名称为 build-and-deploy,简化部署流程 - 更新 Action 版本号,统一使用较新的版本 - [release ci] --- .github/workflows/publish-docs.yml | 99 ++++++++---------------------- 1 file changed, 27 insertions(+), 72 deletions(-) diff --git a/.github/workflows/publish-docs.yml b/.github/workflows/publish-docs.yml index 1cbb250..b98ba88 100644 --- a/.github/workflows/publish-docs.yml +++ b/.github/workflows/publish-docs.yml @@ -1,106 +1,61 @@ -# 工作流名称:Publish Docs -# 该工作流用于在推送到 main 分支时自动构建并发布文档到 GitHub Pages。 -# 暂时关了,目前这个文档生成有问题,以后再改 +# 工作流名称:Publish Docs (VitePress) name: Publish Docs -# 触发条件: -# 定义工作流的触发规则。当代码仓库发生特定事件时,将自动执行相关操作。 -# 此处配置表示:当向仓库推送(push)带有标签(tag)的提交时触发工作流。 -# 标签匹配规则为通配符 '*',即任意标签都会触发。 on: -# push: -# branches: -# - '**' -# tags: -# - '*' - workflow_dispatch: - -# 权限配置:指定工作流所需的权限。 -# actions: read - 允许读取 GitHub Actions 相关信息。 -# pages: write - 允许写入 GitHub Pages 内容。 -# id-token: write - 允许写入身份令牌(用于部署认证)。 + push: + branches: + - '**' + tags: + - '*' permissions: - actions: read + contents: read pages: write id-token: write -# 并发控制:确保同一组任务不会同时运行。 -# group: "pages" - 将并发任务分组为 "pages"。 -# cancel-in-progress: false - 不取消正在进行的任务。 concurrency: group: "pages" cancel-in-progress: false -# 定义工作流中的作业。 -# if 条件表达式用于判断是否执行该作业。 -# 表达式逻辑如下: -# 1. startsWith(github.ref, 'refs/tags/'):检查当前引用是否以 'refs/tags/' 开头,即是否为标签推送。 -# 2. contains(github.event.head_commit.message, '[release doc]'):检查提交信息中是否包含 '[release doc]' 字符串。 -# 若任一条件满足,则执行该作业。 jobs: - # 作业名称:publish-docs,负责构建和发布文档。 - publish-docs: - if: | - startsWith(github.ref, 'refs/tags/') - || contains(github.event.head_commit.message, '[release doc]') - # 运行环境:使用最新版本的 Ubuntu 虚拟机。 + build-and-deploy: runs-on: ubuntu-latest - # 环境配置:指定部署的目标环境为 github-pages,并设置页面 URL。 + environment: name: github-pages url: ${{ steps.deployment.outputs.page_url }} - # 步骤定义:按顺序执行一系列操作以完成文档构建与发布。 steps: - # 步骤 1:检出代码仓库。 + # 1️⃣ 拉取仓库代码 - name: Checkout - uses: actions/checkout@v6 + uses: actions/checkout@v4 - # 步骤 2:安装 .NET SDK。 - - name: Setup .NET - uses: actions/setup-dotnet@v5 + # 2️⃣ 安装 Node.js + - name: Setup Node + uses: actions/setup-node@v4 with: - dotnet-version: 10.0.x + node-version: 20 + cache: 'npm' - # 步骤 3:恢复项目依赖项。 - - name: Restore - run: dotnet restore - - # 步骤 4:构建项目并生成 XML 文档。 - - name: Build (generate XML docs) - run: dotnet build -c Release - - # 步骤 5:安装 DocFX 工具。 - - name: Install DocFX - run: dotnet tool update -g docfx - - # 步骤 6:使用 DocFX 构建静态站点。 - - name: Build DocFX + # 3️⃣ 安装依赖 + - name: Install Dependencies run: | - export PATH="$PATH:$HOME/.dotnet/tools" - cd docfx - docfx metadata - docfx build + cd docs + npm install - - name: Debug DocFX output + # 4️⃣ 构建 VitePress + - name: Build VitePress run: | - echo "==== docfx directory ====" - ls -la docfx || true + cd docs + npm run build - echo "==== _site directory ====" - ls -la docfx/_site || echo "_site not found" - - echo "==== _site content ====" - find docfx/_site | head -n 50 || true - - # 步骤 7:上传构建好的静态站点文件作为工件。 + # 5️⃣ 上传构建产物 - name: Upload Pages Artifact uses: actions/upload-pages-artifact@v3 with: - path: docfx/_site + path: docs/.vitepress/dist - # 步骤 8:将静态站点部署到 GitHub Pages。 + # 6️⃣ 部署到 GitHub Pages - name: Deploy to GitHub Pages id: deployment uses: actions/deploy-pages@v4