1e0ce71b30
Doxygen to Wiki (Gitea-native) / Build Doxygen and publish to Wiki (push) Failing after 27s
146 lines
5.3 KiB
YAML
146 lines
5.3 KiB
YAML
# Publish Doxygen HTML to the repository Wiki via Gitea Actions
|
|
# Requirements:
|
|
# - Create a repository secret named WIKI_TOKEN with a Personal Access Token that has write access.
|
|
# - Ensure the Wiki is enabled for this repository.
|
|
# - Doxygen output is expected at docs/html (from Doxyfile: OUTPUT_DIRECTORY = docs).
|
|
|
|
name: Doxygen to Wiki (Gitea-native)
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- main
|
|
- master
|
|
paths:
|
|
- '**.py'
|
|
- '**.md'
|
|
- 'Doxyfile'
|
|
- '.gitea/workflows/doxygen-to-wiki.yml'
|
|
workflow_dispatch:
|
|
|
|
permissions: {}
|
|
|
|
jobs:
|
|
publish:
|
|
name: Build Doxygen and publish to Wiki
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout repository
|
|
uses: actions/checkout@v4
|
|
with:
|
|
fetch-depth: 0
|
|
|
|
- name: Install Doxygen, Graphviz, build tools, and build doxybook2 from source
|
|
shell: bash
|
|
run: |
|
|
set -euo pipefail
|
|
sudo apt-get update
|
|
sudo apt-get install -y doxygen graphviz rsync curl ca-certificates jq git build-essential cmake pkg-config ninja-build
|
|
|
|
# Build doxybook2 from source (latest release tag). If API fails, use master.
|
|
TAG="$(curl -fsSL https://api.github.com/repos/matusnovak/doxybook2/releases/latest | jq -r .tag_name || true)"
|
|
if [ -z "${TAG}" ] || [ "${TAG}" = "null" ]; then
|
|
TAG="master"
|
|
fi
|
|
|
|
rm -rf /tmp/doxybook2
|
|
git clone --depth 1 --branch "${TAG}" https://github.com/matusnovak/doxybook2.git /tmp/doxybook2
|
|
git -C /tmp/doxybook2 submodule update --init --recursive || true
|
|
|
|
# Prefer Ninja if available, fall back to Makefiles
|
|
cmake -S /tmp/doxybook2 -B /tmp/doxybook2/build -G "Ninja" -DCMAKE_BUILD_TYPE=Release || \
|
|
cmake -S /tmp/doxybook2 -B /tmp/doxybook2/build -DCMAKE_BUILD_TYPE=Release
|
|
cmake --build /tmp/doxybook2/build -j"$(nproc)"
|
|
|
|
# Install to /usr/local/bin; prefer CMake install, fallback to manual install
|
|
if sudo cmake --install /tmp/doxybook2/build 2>/dev/null; then
|
|
:
|
|
else
|
|
BIN="$(find /tmp/doxybook2/build -type f -executable -name doxybook2 -print -quit)"
|
|
if [ -z "${BIN}" ]; then
|
|
echo "doxybook2 binary not found in build output" >&2
|
|
exit 1
|
|
fi
|
|
sudo install -m 0755 "${BIN}" /usr/local/bin/doxybook2
|
|
fi
|
|
|
|
doxybook2 --version
|
|
|
|
- name: Build Doxygen (HTML + XML)
|
|
shell: bash
|
|
run: |
|
|
set -euo pipefail
|
|
rm -rf docs/html docs/xml
|
|
doxygen Doxyfile
|
|
test -d docs/xml || { echo "Doxygen XML output not found at docs/xml"; exit 2; }
|
|
|
|
- name: Publish to Wiki
|
|
env:
|
|
WIKI_TOKEN: ${{ secrets.WIKI_TOKEN }}
|
|
shell: bash
|
|
run: |
|
|
set -euo pipefail
|
|
|
|
if [ -z "${WIKI_TOKEN:-}" ]; then
|
|
echo "Missing WIKI_TOKEN secret. Create it with a PAT that has wiki write access." >&2
|
|
exit 1
|
|
fi
|
|
|
|
# Derive server host and repo slug from the existing 'origin' remote
|
|
ORIGIN_URL="$(git remote get-url origin)"
|
|
case "${ORIGIN_URL}" in
|
|
http://*|https://*)
|
|
SERVER_HOST="$(echo "${ORIGIN_URL}" | sed -E 's#^https?://([^/]+)/.*#\1#')"
|
|
PATH_PART="$(echo "${ORIGIN_URL}" | sed -E 's#^https?://[^/]+/##')"
|
|
;;
|
|
git@*:* )
|
|
SERVER_HOST="$(echo "${ORIGIN_URL}" | sed -E 's#^git@([^:]+):.*#\1#')"
|
|
PATH_PART="$(echo "${ORIGIN_URL}" | sed -E 's#^git@[^:]+:##')"
|
|
;;
|
|
*)
|
|
echo "Unsupported origin URL format: ${ORIGIN_URL}" >&2
|
|
exit 4
|
|
;;
|
|
esac
|
|
# Remove optional .git suffix
|
|
REPO_SLUG="${PATH_PART%.git}"
|
|
|
|
# Clone wiki with token via HTTP header (no username needed)
|
|
rm -rf wiki
|
|
WIKI_URL="https://${SERVER_HOST}/${REPO_SLUG}.wiki.git"
|
|
echo "Cloning wiki from ${WIKI_URL}"
|
|
git -c http.extraHeader="Authorization: token ${WIKI_TOKEN}" clone "${WIKI_URL}" wiki || {
|
|
echo "Wiki repo may not be initialized; create a placeholder page in the UI." >&2
|
|
exit 3
|
|
}
|
|
|
|
# Configure token for pushes to this host
|
|
git -C wiki config http."https://${SERVER_HOST}/".extraHeader "Authorization: token ${WIKI_TOKEN}"
|
|
|
|
# Convert Doxygen XML to Markdown into wiki/Doxygen
|
|
rm -rf wiki/Doxygen wiki/doxygen
|
|
mkdir -p wiki/Doxygen
|
|
doxybook2 --input docs/xml --output wiki/Doxygen
|
|
|
|
# Create/overwrite the landing page
|
|
cat > wiki/Doxygen.md << 'EOF'
|
|
# Doxygen Documentation
|
|
|
|
The generated API reference is published as native Markdown pages under the Doxygen directory in this wiki.
|
|
|
|
- Open the entry point (if present): [Doxygen/index.md](Doxygen/index.md)
|
|
- Or browse the Doxygen/ pages listed in the sidebar
|
|
EOF
|
|
|
|
# Commit and push
|
|
COMMIT_SHA="$(git rev-parse --short HEAD || echo)"
|
|
cd wiki
|
|
git config user.name "wiki-bot"
|
|
git config user.email "wiki-bot@local"
|
|
git add -A
|
|
if git diff --cached --quiet; then
|
|
echo "No changes to publish."
|
|
exit 0
|
|
fi
|
|
git commit -m "docs: update doxygen site from ${COMMIT_SHA}"
|
|
git push origin HEAD |