Files
Manlink_Doc/.gitea/workflows/sphinx_test.yml
T
yuysh 6f7975959f
Build Sphinx Documentation / Build Documentation from PR Branch (pull_request) Failing after 3m5s
New action test
2025-08-25 12:56:59 +08:00

55 lines
2.0 KiB
YAML

name: Build Sphinx Documentation
on:
pull_request:
types: [opened, synchronize, reopened, edited]
branches: [master]
jobs:
build-docs:
name: Build Documentation from PR Branch
runs-on: linux
steps:
# 第一步:检出PR分支代码
- name: Checkout PR branch
uses: actions/checkout@v4
with:
ref: ${{ github.head_ref }} # 检出PR分支而不是主分支
fetch-depth: 0
# 第二步:设置Python虚拟环境
- name: Set up Python virtual environment
run: |
echo "Setting up Python environment for PR branch"
python -m venv /home/ly0kos/work/test_env/.venv-pr-${{ github.head_ref }}
source /home/ly0kos/work/test_env/.venv-pr-${{ github.head_ref }}/bin/activate
pip install --upgrade pip
if [ -f requirements.txt ]; then
pip install -r requirements.txt
else
echo "No requirements.txt found, installing sphinx"
pip install sphinx
fi
# 第三步:构建文档(从PR分支)
- name: Build documentation from PR branch
run: |
echo "=== Building documentation from PR branch: ${{ github.head_ref }} ==="
source /home/ly0kos/work/test_env/.venv-pr-${{ github.head_ref }}/bin/activate
# 在PR分支目录中构建
sphinx-build -b html ./docs ./build -v -j 4
# 将构建结果移动到共享位置,便于查看
rm -rf /home/ly0kos/work/test_env/pr-builds/${{ github.head_ref }}
mkdir -p /home/ly0kos/work/test_env/pr-builds/${{ github.head_ref }}
cp -r ./build/* /home/ly0kos/work/test_env/pr-builds/${{ github.head_ref }}/
echo "✓ Build completed for PR branch: ${{ github.head_ref }}"
# 第四步:验证构建结果
- name: Verify build
run: |
echo "Build output for PR ${{ github.head_ref }}:"
ls -la /home/ly0kos/work/test_env/pr-builds/${{ github.head_ref }}/ | head -10