docs #281
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: docs | |
| on: | |
| schedule: | |
| - cron: '0 0 * * *' # 每天UTC时间0:00执行 | |
| push: | |
| branches: | |
| - master | |
| workflow_dispatch: | |
| jobs: | |
| docs: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v5 | |
| with: | |
| fetch-depth: 0 | |
| submodules: 'recursive' | |
| - name: Update Docs | |
| continue-on-error: true | |
| run: | | |
| git config --local user.email "action@github.com" | |
| git config --local user.name "GitHub Action" | |
| git pull | |
| git submodule update --init | |
| git submodule update --remote | |
| git add . | |
| if git diff --staged --quiet; then | |
| echo "跳过更新:子模块没有变化" | |
| else | |
| git commit -m "chore(docs): 自动更新子模块 [skip ci]" | |
| git push | |
| fi | |
| - name: Update TShock Wiki | |
| continue-on-error: true | |
| run: | | |
| # 更新 TShock Wiki 子模块 | |
| git submodule update --remote TShockWiki | |
| # 创建目标目录 | |
| mkdir -p docs/zh/tshock-wiki | |
| # 从子模块复制文件 | |
| cp -r TShockWiki/* docs/zh/tshock-wiki/ | |
| # 删除 .git 目录 | |
| rm -rf docs/zh/tshock-wiki/.git | |
| cd docs/zh/tshock-wiki | |
| # 删除非中文文档 | |
| find . -name "*.md" -not -name "*(中文)*" -not -name "get-start.md" -not -name "README-维护说明.md" -delete | |
| # 修复中文文档标题 | |
| for file in $(find . -name "*(中文)*.md"); do | |
| if [ -f "$file" ]; then | |
| content=$(cat "$file") | |
| # 检查是否已有一级标题 | |
| if ! echo "$content" | grep -q "^# "; then | |
| title=$(basename "$file" .md | sed 's/(中文)//g') | |
| echo -e "# $title\n\n$content" > "$file" | |
| echo "已为 $file 添加标题: # $title" | |
| fi | |
| fi | |
| done | |
| # 确保入口文件存在 | |
| if [ ! -f "get-start.md" ]; then | |
| echo "⚠ 入口文件不存在,跳过处理" | |
| fi | |
| cd ../../.. | |
| - name: Copy Docs | |
| shell: pwsh | |
| run: | | |
| ./scripts/copy_docs.ps1 | |
| - name: localize Image | |
| shell: pwsh | |
| run: | | |
| ./scripts/local_img.ps1 | |
| - name: Install pnpm | |
| uses: pnpm/action-setup@v4 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v5 | |
| with: | |
| cache: pnpm | |
| - name: Install dependencies | |
| run: pnpm install --frozen-lockfile | |
| - name: Build documentation site | |
| run: pnpm docs:build | |
| - name: Deploy to GitHub Pages | |
| uses: crazy-max/ghaction-github-pages@v4 | |
| with: | |
| fqdn: docs.terraria.ink | |
| repo: UnrealMultiple/UnrealMultiple.github.io | |
| target_branch: master | |
| build_dir: docs/.vuepress/dist | |
| env: | |
| GH_PAT: ${{ secrets.GH_PAGES_TOKEN }} |