1+ name : Build & Deploy Sphinx Docs
2+
3+ on :
4+ push :
5+ branches :
6+ - main
7+ - master
8+ pull_request :
9+ workflow_dispatch :
10+
11+ jobs :
12+ build-and-deploy :
13+ runs-on : ubuntu-latest
14+
15+ steps :
16+ # 1. Checkout the repo
17+ - name : Checkout repository
18+ uses : actions/checkout@v4
19+
20+ # 2. Set up Python
21+ - name : Set up Python
22+ uses : actions/setup-python@v5
23+ with :
24+ python-version : ' 3.12'
25+
26+ # 3. Install dependencies
27+ - name : Install dependencies
28+ run : |
29+ python -m pip install --upgrade pip
30+ # pip install numpy matplotlib pandas scipy sphinx_rtd_theme rst2pdf sphinx pytest irelease sphinxcontrib-fulltoc tabulate
31+ pip install -r requirements-dev.txt || true
32+ pip install -r requirements.txt || true
33+
34+ # 4. Build HTML docs
35+ - name : Build HTML
36+ working-directory : ./docs
37+ run : |
38+ make clean
39+ make html
40+
41+ # 5. Verify build and copy files
42+ - name : Verify build and copy files
43+ run : |
44+ # Debug: Show current working directory
45+ echo "=== Current working directory ==="
46+ pwd
47+ echo "=== Current directory contents ==="
48+ ls -la
49+
50+ # Debug: List what was created
51+ echo "=== Contents of docs/pages/html ==="
52+ ls -la ./docs/pages/html/ || echo "docs/pages/html/ does not exist"
53+
54+ # Create docs/pages folder if it doesn't exist
55+ echo "=== Creating docs/pages directory ==="
56+ mkdir -p ./docs/pages
57+ echo "=== docs/pages directory created ==="
58+ ls -la ./docs/pages/ || echo "docs/pages/ still does not exist"
59+
60+ # Copy built HTML files to docs/pages folder
61+ echo "=== Copying files ==="
62+ cp -rv ./docs/pages/html/* ./docs/pages/ || echo "Copy failed with exit code $?"
63+
64+ # Verify copy worked
65+ echo "=== Contents of docs/pages after copy ==="
66+ ls -la ./docs/pages/ || echo "docs/pages/ does not exist"
67+
68+ # Show file sizes to verify copy
69+ echo "=== File sizes in docs/pages ==="
70+ du -sh ./docs/pages/ || echo "Cannot check docs/pages size"
71+
72+ # 6. Deploy to docs/pages/ folder on main branch
73+ - name : Deploy to docs/pages/ folder
74+ run : |
75+ # Configure git
76+ git config --global user.name "github-actions"
77+ git config --global user.email "actions@github.com"
78+
79+ # Debug: Show what we're about to commit
80+ echo "=== Git status ==="
81+ git status
82+
83+ # Add and commit changes
84+ git add ./docs/pages/
85+ git commit -m "Update Sphinx documentation" || echo "No changes"
86+ git push origin master
87+
0 commit comments