chapter5-*: 完善调试器三层架构设计\前后端分离式架构设计的相关内容 #143
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: Auto Deploy GitBook | |
| on: | |
| push: | |
| branches: [ main, master ] | |
| workflow_dispatch: # 允许手动触发 | |
| jobs: | |
| deploy: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout source code | |
| uses: actions/checkout@v4 | |
| - name: Build and Deploy GitBook | |
| run: | | |
| # 创建临时目录 | |
| tmpdir=$(mktemp -d) | |
| builddir=$(mktemp -d) | |
| # 清理函数 | |
| cleanup() { | |
| rm -rf "$tmpdir" 2>/dev/null || true | |
| rm -rf "$builddir" 2>/dev/null || true | |
| } | |
| trap cleanup EXIT | |
| echo "🚀 Starting GitBook build and deployment..." | |
| # 克隆目标仓库(使用带token的HTTPS URL) | |
| echo "📥 Cloning target repository..." | |
| git clone --depth 1 https://${{ secrets.DEPLOY_TOKEN }}@github.com/hitzhangjie/debugger101.io $tmpdir | |
| # 使用Docker构建GitBook | |
| echo "🔨 Building GitBook with Docker..." | |
| docker run --name gitbook --rm \ | |
| -v ${PWD}:/root/gitbook \ | |
| -v $builddir:$builddir \ | |
| hitzhangjie/gitbook-cli:latest \ | |
| bash -c "cd book && gitbook install && cd - && gitbook build book $builddir" | |
| # 复制构建结果到目标目录 | |
| echo "📋 Copying build results..." | |
| cp -rf $builddir/* $tmpdir/ | |
| # 提交更改 | |
| echo "💾 Committing changes..." | |
| cd $tmpdir | |
| git config --local user.name "hitzhangjie" | |
| git config --local user.email "hit.zhangjie@gmail.com" | |
| git add . | |
| git commit -m "Auto-deploy: $(date)" | |
| # 使用 URL 重写方式推送,避免写入凭证文件 | |
| git remote set-url origin https://${{ secrets.DEPLOY_TOKEN }}@github.com/hitzhangjie/debugger101.io | |
| git push -f -u origin master | |
| cd - | |
| echo "✅ Deployment completed successfully!" |