63 lines
1.5 KiB
YAML
63 lines
1.5 KiB
YAML
name: 构建和部署文档
|
|
# Build and Deploy Documentation
|
|
|
|
on:
|
|
push:
|
|
branches: [ main, master ]
|
|
pull_request:
|
|
branches: [ main, master ]
|
|
|
|
jobs:
|
|
build-docs:
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
- name: 检出代码
|
|
uses: actions/checkout@v4
|
|
|
|
- name: 设置Python环境
|
|
uses: actions/setup-python@v4
|
|
with:
|
|
python-version: '3.11'
|
|
|
|
- name: 安装依赖
|
|
run: |
|
|
python -m pip install --upgrade pip
|
|
pip install -r documentation/sphinx-docs/requirements.txt
|
|
|
|
- name: 构建Sphinx文档
|
|
run: |
|
|
cd documentation/sphinx-docs
|
|
make html
|
|
|
|
- name: 部署到GitHub Pages
|
|
if: github.ref == 'refs/heads/main'
|
|
uses: peaceiris/actions-gh-pages@v3
|
|
with:
|
|
github_token: ${{ secrets.GITHUB_TOKEN }}
|
|
publish_dir: ./documentation/sphinx-docs/_build/html
|
|
|
|
deploy-local:
|
|
runs-on: self-hosted
|
|
if: github.ref == 'refs/heads/main'
|
|
needs: build-docs
|
|
|
|
steps:
|
|
- name: 检出代码
|
|
uses: actions/checkout@v4
|
|
|
|
- name: 构建文档
|
|
run: |
|
|
./build_docs.sh
|
|
|
|
- name: 启动本地服务器
|
|
run: |
|
|
# 停止旧的服务器
|
|
pkill -f "python.*http.server.*8000" || true
|
|
|
|
# 启动新的服务器
|
|
nohup python3 -m http.server 8000 \
|
|
--directory documentation/sphinx-docs/_build/html \
|
|
> server.log 2>&1 &
|
|
|
|
echo "文档服务器已启动: http://localhost:8000" |