Files
dao-os-docs/.gitea/workflows/build_and_deploy_docs.yml
李东云 1a8b8431cc
Some checks failed
Build and Deploy mdBook / build-and-deploy (push) Failing after 9s
🐎 ci: add i18n
2025-06-11 13:32:31 +08:00

49 lines
2.1 KiB
YAML
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
name: Build and Deploy mdBook
on:
push:
branches:
- main
jobs:
build-and-deploy:
runs-on: ubuntu-latest # 我们使用 GitOps 模式,不再需要特殊 Runner
steps:
- name: Checkout repository
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Install mdBook
uses: peaceiris/actions-mdbook@v1
# --- ↓↓↓ 核心变更:分两次独立构建 ↓↓↓ ---
- name: Build English & Chinese Books Separately
run: |
echo "Building English book..."
# 使用 en 的配置,构建英文版,并指定输出到 book/en 目录
mdbook build -d $(pwd)/book/en en
echo "Building Chinese book..."
# 使用 zh 的配置,构建中文版,并指定输出到 book/zh 目录
mdbook build -d $(pwd)/book/zh zh
- name: Create Language Redirect Index
run: |
# 这个步骤依然需要,用于创建根目录的语言跳转页
echo '<!DOCTYPE html><html><head><meta charset="utf-8"><title>Redirecting...</title><script>var lang = navigator.language || navigator.userLanguage; if (lang.toLowerCase().startsWith("zh")) { window.location.replace("./zh/"); } else { window.location.replace("./en/"); }</script><meta http-equiv="refresh" content="0; url=./en/"></head><body><p>Redirecting to your preferred language... If you are not redirected, please select a language:</p><p><a href="./en/">English</a> | <a href="./zh/">简体中文</a></p></body></html>' > book/index.html
echo "Created language redirect page."
# --- ↓↓↓ 部署步骤保持不变 ↓↓↓ ---
- name: Deploy to 'pages' branch
uses: peaceiris/actions-gh-pages@v3
with:
personal_token: ${{ secrets.DEPLOY_TOKEN }}
external_repository: Dao-OS/dao-os-docs
publish_branch: pages
publish_dir: ./book # 推送整个 book 目录(现在包含了 en 和 zh
user_name: "Gitea Actions"
user_email: "actions@gitea.example.com"
gitea_server: nest.doylee.cn