3proxy/.github/workflows/update-docs.yml
Vladimir Dubrovin 22c7dfe0e1 Generate HTML documentation from man pages in a workflow
The HTML under doc/html was produced by a script kept outside this repository,
so editing a man page and refreshing its HTML were separate manual steps and
the two could drift apart.

Run the same groff conversion in a workflow triggered by a change under man/.
It rebuilds doc/html/index.html and the man5 and man8 pages, and commits only
when something actually changed.

Output was verified byte for byte against the committed tree: all twelve man
pages and index.html are reproduced exactly.
2026-08-22 14:23:13 +03:00

52 lines
2.2 KiB
YAML

name: Update HTML documentation
on:
push:
paths:
- 'man/**'
workflow_dispatch:
permissions:
contents: read
jobs:
docs:
permissions:
contents: write
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- name: Install groff
run: |
sudo apt-get update
sudo apt-get install -y groff
- name: Generate HTML from man pages
run: |
mkdir -p doc/html/man5 doc/html/man8
echo \<html\>\<title\>3proxy documentation\</title\>\<body\>\<h2\>3proxy documentation\</h2\> >doc/html/index.html
echo \<a href=\"securityen.html\"\>Security recommendations\</a\>\<br\> >>doc/html/index.html
echo \<a href=\"highload.html\"\>Optimizing 3proxy for high loads\</a\>\<br\> >>doc/html/index.html
echo \<a href=\"howtoe.html\"\>How To \(English, very incomplete\)\</a\>\<br\> >>doc/html/index.html
echo \<a href=\"howtor.html\"\>How To \(Russian\)\</a\>\<br\> >>doc/html/index.html
echo \<a href=\"devref.html\"\>Developer reference\</a\>\<br\> >>doc/html/index.html
echo \<h3\>Man pages:\</h3\> >>doc/html/index.html
cd man
for i in *.8; do ((bash -c "groff -mandoc -Thtml $i | grep -v DOCTYPE| grep -v text/css| grep -v 'meta ' | grep -v /style | grep -v { | grep -v /title | grep -v www.w3.org | grep -v CreationDate" > ../doc/html/man8/$i.html ) && echo \<br\>\<A HREF=\"man8/$i.html\"\>$i\</A\> >> ../doc/html/index.html); done
for i in *.5; do ((bash -c "groff -mandoc -Thtml $i | grep -v DOCTYPE| grep -v text/css| grep -v 'meta ' | grep -v /style | grep -v { | grep -v /title | grep -v www.w3.org | grep -v CreationDate" > ../doc/html/man5/$i.html ) && echo \<br\>\<A HREF=\"man5/$i.html\"\>$i\</A\> >> ../doc/html/index.html); done
cd ..
echo \</body\>\</html\> >>doc/html/index.html
- name: Commit
run: |
if [ -z "$(git status --porcelain doc/html)" ]; then
echo "documentation already up to date"
exit 0
fi
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git add doc/html
git commit -m "Update HTML documentation from man pages"
git push