From 951e28f27c3489f8bcb25b853202eccd784f1cba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E4=B8=9C=E4=BA=91?= Date: Tue, 10 Jun 2025 04:24:21 +0800 Subject: [PATCH] =?UTF-8?q?ci(=E6=96=87=E6=A1=A3):=20=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E5=A4=9A=E8=AF=AD=E8=A8=80=E6=96=87=E6=A1=A3=E6=9E=84=E5=BB=BA?= =?UTF-8?q?=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 添加英文和中文的文档配置文件,并修改CI流程以支持多语言独立构建 将构建输出分别放入book/en和book/zh目录 保留语言自动跳转功能 --- .gitea/workflows/build_and_deploy_docs.yml | 35 +++++++++++++--------- .gitignore | 1 + book.toml => book.en.toml | 11 ------- book.zh.toml | 8 +++++ 4 files changed, 30 insertions(+), 25 deletions(-) rename book.toml => book.en.toml (61%) create mode 100644 book.zh.toml diff --git a/.gitea/workflows/build_and_deploy_docs.yml b/.gitea/workflows/build_and_deploy_docs.yml index d77c1e8..7af58cb 100644 --- a/.gitea/workflows/build_and_deploy_docs.yml +++ b/.gitea/workflows/build_and_deploy_docs.yml @@ -1,41 +1,48 @@ -name: Build and Deploy mdBook to Pages Branch +name: Build and Deploy mdBook on: push: branches: - # 只有 main 分支的变更才会触发部署 - main jobs: build-and-deploy: - runs-on: ubuntu-latest # 现在我们可以用通用的 Runner,不再需要挂载数据卷 + runs-on: ubuntu-latest # 我们使用 GitOps 模式,不再需要特殊 Runner steps: - name: Checkout repository uses: actions/checkout@v2 with: - # 获取所有历史记录,以便 peaceiris/actions-gh-pages 操作 fetch-depth: 0 - name: Install mdBook uses: peaceiris/actions-mdbook@v1 - - name: Build mdBook - run: mdbook build + # --- ↓↓↓ 核心变更:分两次独立构建 ↓↓↓ --- + - name: Build English & Chinese Books Separately + run: | + echo "Building English book..." + # 使用 en 的配置,构建英文版,并指定输出到 book/en 目录 + mdbook build -d book/en --config book.en.toml . + echo "Building Chinese book..." + # 使用 zh 的配置,构建中文版,并指定输出到 book/zh 目录 + mdbook build -d book/zh --config book.zh.toml . + + - name: Create Language Redirect Index + run: | + # 这个步骤依然需要,用于创建根目录的语言跳转页 + echo 'Redirecting...

Redirecting to your preferred language... If you are not redirected, please select a language:

English | 简体中文

' > book/index.html + echo "Created language redirect page." + + # --- ↓↓↓ 部署步骤保持不变 ↓↓↓ --- - name: Deploy to 'pages' branch uses: peaceiris/actions-gh-pages@v3 with: - # 我们用 personal_token 替代默认的 github_token - personal_token: d58a2e62b51446633a0c87df1591ba34db1ecacb - # 指定 Gitea 服务器的地址 + personal_token: ${{ secrets.DEPLOY_TOKEN }} external_repository: Dao-OS/dao-os-docs - # 要推送到哪个分支 publish_branch: pages - # 要推送哪个目录下的内容 - publish_dir: ./book - # 提交代码的用户信息 + publish_dir: ./book # 推送整个 book 目录(现在包含了 en 和 zh) user_name: "Gitea Actions" user_email: "actions@gitea.example.com" - # Gitea 需要这个设置 gitea_server: nest.doylee.cn diff --git a/.gitignore b/.gitignore index e69de29..4e42a1b 100644 --- a/.gitignore +++ b/.gitignore @@ -0,0 +1 @@ +book/ \ No newline at end of file diff --git a/book.toml b/book.en.toml similarity index 61% rename from book.toml rename to book.en.toml index 4c10640..3500994 100644 --- a/book.toml +++ b/book.en.toml @@ -2,18 +2,7 @@ title = "Dao OS Documentation" author = "The Dao OS Community" description = "The official documentation for the Dao OS, your Cyber-Life Operating System." -multi-lingual = true -default-language = "en" - -[language.en] -language = "en" -name = "English" src = "src" -[language.zh] -language = "zh" -name = "简体中文" -src = "src-zh" - [output.html] git-repository-url = "https://nest.doylee.cn/Dao-OS/dao-os-docs" diff --git a/book.zh.toml b/book.zh.toml new file mode 100644 index 0000000..0127a51 --- /dev/null +++ b/book.zh.toml @@ -0,0 +1,8 @@ +[book] +title = "大道 (Dao OS) 文档" +author = "The Dao OS Community" +description = "大道(Dao OS)官方文档,你的赛博生命操作系统。" +src = "src-zh" + +[output.html] +git-repository-url = "https://nest.doylee.cn/Dao-OS/dao-os-docs"