Skip to content

Commit b0de502

Browse files
committed
Fix GitHub Pages deployment permissions and add alternative workflow
- Updated docs.yml with proper permissions and combined deployment - Added explicit permissions for contents, pages, and id-token - Created alternative docs-deploy.yml using official GitHub Pages actions - Combined documentation into single deployment with proper navigation - Added force_orphan option to avoid branch conflicts
1 parent 474f048 commit b0de502

File tree

2 files changed

+156
-9
lines changed

2 files changed

+156
-9
lines changed

.github/workflows/docs-deploy.yml

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
name: Deploy Documentation to GitHub Pages
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
paths:
7+
- 'include/**'
8+
- 'examples/**'
9+
- 'docs/**'
10+
- 'Doxyfile'
11+
- 'tools/scripts/build_docs.sh'
12+
13+
permissions:
14+
contents: read
15+
pages: write
16+
id-token: write
17+
18+
# Allow only one concurrent deployment
19+
concurrency:
20+
group: "pages"
21+
cancel-in-progress: false
22+
23+
jobs:
24+
build:
25+
runs-on: ubuntu-latest
26+
27+
steps:
28+
- name: Checkout code
29+
uses: actions/checkout@v4
30+
31+
- name: Setup Python
32+
uses: actions/setup-python@v4
33+
with:
34+
python-version: '3.11'
35+
36+
- name: Install system dependencies
37+
run: |
38+
sudo apt-get update
39+
sudo apt-get install -y doxygen graphviz plantuml
40+
41+
- name: Install Python dependencies
42+
run: |
43+
python -m pip install --upgrade pip
44+
pip install sphinx sphinx-rtd-theme breathe exhale
45+
46+
- name: Make build script executable
47+
run: chmod +x tools/scripts/build_docs.sh
48+
49+
- name: Generate documentation
50+
run: |
51+
./tools/scripts/build_docs.sh all
52+
53+
- name: Create combined documentation site
54+
run: |
55+
mkdir -p _site
56+
cp -r docs/generated/html/* _site/
57+
mkdir -p _site/sphinx
58+
cp -r docs/sphinx/_build/html/* _site/sphinx/
59+
mkdir -p _site/api
60+
cp -r docs/api/* _site/api/
61+
62+
# Create a main index.html
63+
cat > _site/index.html << 'EOF'
64+
<!DOCTYPE html>
65+
<html>
66+
<head>
67+
<meta charset="UTF-8">
68+
<title>DiffEq Documentation</title>
69+
<meta http-equiv="refresh" content="0; url=./annotated.html">
70+
<style>
71+
body { font-family: Arial, sans-serif; margin: 40px; }
72+
.nav { background: #f5f5f5; padding: 20px; border-radius: 5px; }
73+
.nav h1 { color: #333; }
74+
.nav a { display: block; margin: 10px 0; padding: 10px; background: #007acc; color: white; text-decoration: none; border-radius: 3px; }
75+
.nav a:hover { background: #005a99; }
76+
</style>
77+
</head>
78+
<body>
79+
<div class="nav">
80+
<h1>DiffEq Documentation</h1>
81+
<p>If you are not redirected automatically, choose from:</p>
82+
<a href="./annotated.html">📚 API Reference (Doxygen)</a>
83+
<a href="./sphinx/index.html">📖 User Guide (Sphinx)</a>
84+
<a href="./api/README.md">🔧 API Documentation</a>
85+
<a href="https://github.com/WenyinWei/diffeq/tree/main/examples">💡 Examples</a>
86+
</div>
87+
</body>
88+
</html>
89+
EOF
90+
91+
- name: Setup Pages
92+
uses: actions/configure-pages@v4
93+
94+
- name: Upload artifact
95+
uses: actions/upload-pages-artifact@v3
96+
with:
97+
path: '_site'
98+
99+
deploy:
100+
environment:
101+
name: github-pages
102+
url: ${{ steps.deployment.outputs.page_url }}
103+
runs-on: ubuntu-latest
104+
needs: build
105+
106+
steps:
107+
- name: Deploy to GitHub Pages
108+
id: deployment
109+
uses: actions/deploy-pages@v4

.github/workflows/docs.yml

Lines changed: 47 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,11 @@ on:
1818
- 'Doxyfile'
1919
- 'tools/scripts/build_docs.sh'
2020

21+
permissions:
22+
contents: read
23+
pages: write
24+
id-token: write
25+
2126
jobs:
2227
build-docs:
2328
runs-on: ubuntu-latest
@@ -70,6 +75,10 @@ jobs:
7075
needs: build-docs
7176
runs-on: ubuntu-latest
7277
if: github.ref == 'refs/heads/main'
78+
permissions:
79+
contents: read
80+
pages: write
81+
id-token: write
7382

7483
steps:
7584
- name: Checkout code
@@ -93,19 +102,48 @@ jobs:
93102
name: api-docs
94103
path: docs/api/
95104

96-
- name: Deploy to GitHub Pages
97-
uses: peaceiris/actions-gh-pages@v3
98-
with:
99-
github_token: ${{ secrets.GITHUB_TOKEN }}
100-
publish_dir: ./docs/generated/html
101-
destination_dir: ./doxygen
105+
- name: Create combined documentation site
106+
run: |
107+
mkdir -p gh-pages
108+
cp -r docs/generated/html/* gh-pages/
109+
mkdir -p gh-pages/sphinx
110+
cp -r docs/sphinx/_build/html/* gh-pages/sphinx/
111+
mkdir -p gh-pages/api
112+
cp -r docs/api/* gh-pages/api/
102113
103-
- name: Deploy Sphinx to GitHub Pages
114+
# Create a main index.html that redirects to the Doxygen docs
115+
cat > gh-pages/index.html << 'EOF'
116+
<!DOCTYPE html>
117+
<html>
118+
<head>
119+
<meta charset="UTF-8">
120+
<title>DiffEq Documentation</title>
121+
<style>
122+
body { font-family: Arial, sans-serif; margin: 40px; }
123+
.nav { background: #f5f5f5; padding: 20px; border-radius: 5px; }
124+
.nav h1 { color: #333; }
125+
.nav a { display: block; margin: 10px 0; padding: 10px; background: #007acc; color: white; text-decoration: none; border-radius: 3px; }
126+
.nav a:hover { background: #005a99; }
127+
</style>
128+
</head>
129+
<body>
130+
<div class="nav">
131+
<h1>DiffEq Documentation</h1>
132+
<a href="./index.html">📚 API Reference (Doxygen)</a>
133+
<a href="./sphinx/index.html">📖 User Guide (Sphinx)</a>
134+
<a href="./api/README.md">🔧 API Documentation</a>
135+
<a href="https://github.com/WenyinWei/diffeq/tree/main/examples">💡 Examples</a>
136+
</div>
137+
</body>
138+
</html>
139+
EOF
140+
141+
- name: Deploy to GitHub Pages
104142
uses: peaceiris/actions-gh-pages@v3
105143
with:
106144
github_token: ${{ secrets.GITHUB_TOKEN }}
107-
publish_dir: ./docs/sphinx/_build/html
108-
destination_dir: ./sphinx
145+
publish_dir: ./gh-pages
146+
force_orphan: true
109147

110148
docs-check:
111149
runs-on: ubuntu-latest

0 commit comments

Comments
 (0)