Change Actions
Build and Deploy Sphinx Docs / Build Documentation (pull_request) Has been skipped

This commit is contained in:
2025-08-25 12:07:39 +08:00
parent d87300a337
commit aa20b14dcd
2 changed files with 43 additions and 44 deletions
+83
View File
@@ -0,0 +1,83 @@
#For test
name: Build and Deploy Sphinx Docs
on:
pull_request:
types: [opened, synchronize, reopened]
branches: [master]
jobs:
build-docs:
name: Build Documentation
if: github.event.pull_request.merged == true
runs-on: linux
steps:
# 第一步:设置主工作目录和稳定的虚拟环境
- name: Set up main worktree with stable environment
run: |
echo "=== Setting up main worktree ==="
# 创建主工作目录并克隆仓库
if [ ! -d /home/ly0kos/work/test_env ]; then
echo "Cloning repository to main worktree..."
git clone http://localhost:3000/yuysh/Manlink_Doc.git /home/ly0kos/work/test_env
cd /home/ly0kos/work/test_env
echo "Creating virtual environment..."
python -m venv .venv
source .venv/bin/activate
echo "Installing dependencies..."
pip install --upgrade pip
pip install -r requirements.txt
echo "✓ Main worktree and virtual environment created"
else
echo "Updating existing main worktree..."
cd /home/ly0kos/work/test_env
git pull origin main
source .venv/bin/activate
echo "Updating dependencies if needed..."
pip install -r requirements.txt
echo "✓ Main worktree updated"
fi
# 验证环境
echo "Environment verification:"
source .venv/bin/activate
echo "Python: $(python --version)"
echo "Sphinx-build: $(sphinx-build --version 2>/dev/null || echo 'Not found')"
# 第二步:创建临时构建工作树
- name: Create temporary build worktree
run: |
echo "=== Creating build worktree ==="
cd /home/ly0kos/work/test_env
# 清理可能存在的旧构建目录
if [ -d /home/ly0kos/work/test_env/build ]; then
echo "Removing old build worktree..."
git worktree remove /home/ly0kos/work/test_env/build --force 2>/dev/null || true
rm -rf /home/ly0kos/work/test_env/build 2>/dev/null || true
fi
# 创建新的构建工作树
echo "Creating new build worktree..."
git worktree add /home/ly0kos/work/test_env/build
echo "✓ Build worktree created at /home/ly0kos/work/test_env/build"
# 第三步:使用主目录的虚拟环境构建文档
- name: Build documentation
run: |
echo "=== Building documentation ==="
cd /home/ly0kos/work/test_env
source .venv/bin/activate
echo "Building from: /home/ly0kos/work/test_env/source"
echo "Output to: /home/ly0kos/work/test_env/build/build"
# 使用主目录的虚拟环境来构建构建目录中的代码
sphinx-build -b html /home/ly0kos/work/test_env/source /home/ly0kos/work/test_env/build/ -v -j 4
echo "✓ Build completed successfully"
# 验证构建结果
echo "Build output contents:"
ls -la /home/ly0kos/work/test_env/build/