Skip to content

Commit a1778f3

Browse files
committed
workflows: Generate gh-pages automatically
Add a GitHub Action that compiles the Doxygen comments and the man pages in the tlshd source code and builds a .io web site. This is a small step towards improving the published upstream documentation for ktls-utils. Signed-off-by: Chuck Lever <[email protected]>
1 parent f1b0b83 commit a1778f3

File tree

1 file changed

+154
-0
lines changed

1 file changed

+154
-0
lines changed
Lines changed: 154 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,154 @@
1+
---
2+
name: Generate public documentation
3+
4+
on:
5+
release:
6+
types: [published]
7+
workflow_dispatch:
8+
9+
jobs:
10+
generate-docs:
11+
runs-on: ubuntu-latest
12+
permissions:
13+
contents: read
14+
pages: write
15+
id-token: write
16+
environment:
17+
name: github-pages
18+
url: ${{ steps.deployment.outputs.page_url }}
19+
20+
steps:
21+
- uses: actions/checkout@v4
22+
23+
- name: Cache dependencies
24+
uses: actions/cache@v4
25+
with:
26+
path: |
27+
/var/cache/apt
28+
~/.cache
29+
key: ${{ runner.os }}-docs-${{ hashFiles('.github/workflows/documentation.yml') }}
30+
restore-keys: |
31+
${{ runner.os }}-docs-
32+
33+
- name: Install build dependencies
34+
run: |
35+
sudo apt-get update
36+
sudo apt-get -y install \
37+
build-essential \
38+
autoconf \
39+
automake \
40+
gnutls-dev \
41+
libkeyutils-dev \
42+
libnl-3-dev \
43+
libnl-genl-3-dev \
44+
libglib2.0-dev
45+
46+
- name: Install documentation tools
47+
run: |
48+
sudo apt-get update
49+
sudo apt-get install -y \
50+
doxygen \
51+
graphviz \
52+
man2html
53+
54+
- name: Configure
55+
run: |
56+
./autogen.sh
57+
./configure --with-systemd
58+
59+
- name: Generate HTML man pages
60+
run: |
61+
mkdir -p docs/man/html
62+
if ! ls man/man* >/dev/null 2>&1; then
63+
echo "No man page directories found, skipping HTML generation"
64+
exit 0
65+
fi
66+
for section_dir in man/man*
67+
do
68+
if [ ! -d "$section_dir" ]; then
69+
continue
70+
fi
71+
section_num=$(basename "$section_dir" | sed 's/man//')
72+
echo "Processing section $section_num pages..."
73+
find "$section_dir" -name "*.$section_num" -print0 | while IFS= read -r -d '' manpage; do
74+
basename_file=$(basename "$manpage")
75+
section=${basename_file##*.}
76+
name=${basename_file%.*}
77+
if ! man2html "$manpage" > "docs/man/html/${name}.${section}.html"; then
78+
echo "Failed to convert $manpage"
79+
exit 1
80+
fi
81+
done
82+
done
83+
ls -lR docs/man
84+
85+
- name: Generate Doxygen documentation
86+
run: |
87+
(cd docs && doxygen Doxyfile)
88+
89+
- name: Assemble final site
90+
run: |
91+
echo "::group::Assembling Documentation Site"
92+
93+
# Copy Doxygen HTML output
94+
if [ -d docs/doxygen/html ]; then
95+
cp -r docs/doxygen/html _site/
96+
echo "✓ Doxygen HTML documentation copied"
97+
else
98+
echo "✗ No Doxygen HTML documentation found"
99+
exit 1
100+
fi
101+
102+
# Copy man page HTML and index
103+
if [ -d docs/man/html ]; then
104+
cp -r docs/man/html _site/
105+
echo "✓ Manual page documentation copied"
106+
else
107+
echo "ℹ️ No manual pages to copy"
108+
# Create empty man directory with placeholder
109+
mkdir -p _site/man
110+
cat > _site/man/index.html <<EOF
111+
<!DOCTYPE html>
112+
<html><head><title>Manual Pages</title></head>
113+
<body>
114+
<h1>Manual Pages</h1>
115+
<p><a href="../index.html">← Back to Documentation Home</a></p>
116+
<p><em>No manual pages available yet.</em></p>
117+
</body></html>
118+
EOF
119+
fi
120+
121+
# Copy configuration examples
122+
if [ -d docs/examples ]; then
123+
cp -r docs/examples _site/
124+
echo "✓ Configuration examples copied"
125+
else
126+
echo "ℹ️ No configuration examples to copy"
127+
fi
128+
129+
# Add .nojekyll to disable Jekyll processing
130+
touch _site/.nojekyll
131+
132+
# Create sitemap
133+
find _site -name "*.html" | sed 's|_site/||' | while read file; do
134+
echo "https://${{ github.repository_owner }}.github.io/${{ github.event.repository.name }}/$file"
135+
done > _site/sitemap.txt
136+
137+
echo "Documentation site assembled successfully"
138+
echo "Total files: $(find _site -type f | wc -l)"
139+
echo "Site size: $(du -sh _site | cut -f1)"
140+
141+
echo "::endgroup::"
142+
143+
- name: Setup Pages
144+
uses: actions/configure-pages@v4
145+
146+
- name: Upload Pages artifact
147+
uses: actions/upload-pages-artifact@v3
148+
with:
149+
path: _site
150+
151+
- name: Deploy to GitHub Pages
152+
if: github.ref == 'refs/heads/main'
153+
id: deployment
154+
uses: actions/deploy-pages@v4

0 commit comments

Comments
 (0)