90 lines
2.9 KiB
YAML
90 lines
2.9 KiB
YAML
# Publish Doxygen HTML to the repository Wiki via Gitea Actions
|
|
# Requirements:
|
|
# - Create a repository secret named GITEA_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
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- '**'
|
|
paths:
|
|
- '**.py'
|
|
- '**.md'
|
|
- 'Doxyfile'
|
|
- '.gitea/workflows/doxygen-to-wiki.yml'
|
|
workflow_dispatch:
|
|
|
|
permissions:
|
|
contents: read
|
|
|
|
jobs:
|
|
publish:
|
|
name: Build Doxygen and publish to Wiki
|
|
if: ${{ github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master' }}
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout repository
|
|
uses: actions/checkout@v4
|
|
with:
|
|
fetch-depth: 0
|
|
|
|
- name: Install Doxygen and tools
|
|
shell: bash
|
|
run: |
|
|
sudo apt-get update
|
|
sudo apt-get install -y doxygen rsync
|
|
|
|
- name: Build Doxygen site
|
|
shell: bash
|
|
run: |
|
|
doxygen Doxyfile
|
|
test -d docs/html || { echo "Doxygen output not found at docs/html"; exit 2; }
|
|
|
|
- name: Publish to Wiki
|
|
env:
|
|
GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }}
|
|
shell: bash
|
|
run: |
|
|
set -euo pipefail
|
|
if [ -z "${GITEA_TOKEN:-}" ]; then
|
|
echo "Missing GITEA_TOKEN secret. Create a repo secret named GITEA_TOKEN with a PAT that has write access to this repository wiki." >&2
|
|
exit 1
|
|
fi
|
|
# Derive wiki URL: https://<host>/<owner>/<repo>.wiki.git using actor + token for auth
|
|
SERVER="${GITHUB_SERVER_URL}"
|
|
SERVER="${SERVER#https://}"
|
|
SERVER="${SERVER#http://}"
|
|
WIKI_URL="https://${GITHUB_ACTOR}:${GITEA_TOKEN}@${SERVER}/${GITHUB_REPOSITORY}.wiki.git"
|
|
|
|
echo "Cloning wiki repository from ${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}.wiki"
|
|
rm -rf wiki
|
|
git clone "$WIKI_URL" wiki
|
|
|
|
# Sync generated site to wiki/doxygen (clean removed files)
|
|
mkdir -p wiki/doxygen
|
|
rsync -a --delete --checksum docs/html/ wiki/doxygen/
|
|
|
|
# Seed a Doxygen.md landing page if it doesn't exist
|
|
if [ ! -f "wiki/Doxygen.md" ]; then
|
|
printf "%s\n" \
|
|
"# Doxygen Documentation" \
|
|
"" \
|
|
"The generated API reference is published in this wiki under the doxygen directory." \
|
|
"" \
|
|
"- Open the HTML entry point: [doxygen/index.html](doxygen/index.html)" \
|
|
> wiki/Doxygen.md
|
|
fi
|
|
|
|
cd wiki
|
|
git config user.name "${GITHUB_ACTOR}"
|
|
git config user.email "${GITHUB_ACTOR}@users.noreply"
|
|
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 ${GITHUB_SHA}"
|
|
git push origin HEAD |