This commit is contained in:
@@ -1,15 +1,16 @@
|
|||||||
# Publish Doxygen HTML to the repository Wiki via Gitea Actions
|
# Publish Doxygen HTML to the repository Wiki via Gitea Actions
|
||||||
# Requirements:
|
# Requirements:
|
||||||
# - Create a repository secret named GITEA_TOKEN with a Personal Access Token that has write access.
|
# - Create a repository secret named WIKI_TOKEN with a Personal Access Token that has write access.
|
||||||
# - Ensure the Wiki is enabled for this repository.
|
# - Ensure the Wiki is enabled for this repository.
|
||||||
# - Doxygen output is expected at docs/html (from Doxyfile: OUTPUT_DIRECTORY = docs).
|
# - Doxygen output is expected at docs/html (from Doxyfile: OUTPUT_DIRECTORY = docs).
|
||||||
|
|
||||||
name: Doxygen to Wiki
|
name: Doxygen to Wiki (Gitea-native)
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
- '**'
|
- main
|
||||||
|
- master
|
||||||
paths:
|
paths:
|
||||||
- '**.py'
|
- '**.py'
|
||||||
- '**.md'
|
- '**.md'
|
||||||
@@ -17,13 +18,11 @@ on:
|
|||||||
- '.gitea/workflows/doxygen-to-wiki.yml'
|
- '.gitea/workflows/doxygen-to-wiki.yml'
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
|
|
||||||
permissions:
|
permissions: {}
|
||||||
contents: read
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
publish:
|
publish:
|
||||||
name: Build Doxygen and publish to Wiki
|
name: Build Doxygen and publish to Wiki
|
||||||
if: ${{ github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master' }}
|
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout repository
|
- name: Checkout repository
|
||||||
@@ -45,29 +44,52 @@ jobs:
|
|||||||
|
|
||||||
- name: Publish to Wiki
|
- name: Publish to Wiki
|
||||||
env:
|
env:
|
||||||
GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }}
|
WIKI_TOKEN: ${{ secrets.WIKI_TOKEN }}
|
||||||
shell: bash
|
shell: bash
|
||||||
run: |
|
run: |
|
||||||
set -euo pipefail
|
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
|
if [ -z "${WIKI_TOKEN:-}" ]; then
|
||||||
|
echo "Missing WIKI_TOKEN secret. Create it with a PAT that has wiki write access." >&2
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
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"
|
# 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
|
rm -rf wiki
|
||||||
git clone "$WIKI_URL" 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
|
||||||
|
}
|
||||||
|
|
||||||
# Sync generated site to wiki/doxygen (clean removed files)
|
# Configure token for pushes to this host
|
||||||
|
git -C wiki config http."https://${SERVER_HOST}/".extraHeader "Authorization: token ${WIKI_TOKEN}"
|
||||||
|
|
||||||
|
# Sync generated HTML to wiki/doxygen
|
||||||
mkdir -p wiki/doxygen
|
mkdir -p wiki/doxygen
|
||||||
rsync -a --delete --checksum docs/html/ wiki/doxygen/
|
rsync -a --delete --checksum docs/html/ wiki/doxygen/
|
||||||
|
|
||||||
# Seed a Doxygen.md landing page if it doesn't exist
|
# Seed landing page if missing
|
||||||
if [ ! -f "wiki/Doxygen.md" ]; then
|
if [ ! -f "wiki/Doxygen.md" ]; then
|
||||||
printf "%s\n" \
|
printf "%s\n" \
|
||||||
"# Doxygen Documentation" \
|
"# Doxygen Documentation" \
|
||||||
@@ -78,13 +100,15 @@ jobs:
|
|||||||
> wiki/Doxygen.md
|
> wiki/Doxygen.md
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Commit and push
|
||||||
|
COMMIT_SHA="$(git rev-parse --short HEAD || echo)"
|
||||||
cd wiki
|
cd wiki
|
||||||
git config user.name "${GITHUB_ACTOR}"
|
git config user.name "wiki-bot"
|
||||||
git config user.email "${GITHUB_ACTOR}@users.noreply"
|
git config user.email "wiki-bot@local"
|
||||||
git add -A
|
git add -A
|
||||||
if git diff --cached --quiet; then
|
if git diff --cached --quiet; then
|
||||||
echo "No changes to publish."
|
echo "No changes to publish."
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
git commit -m "docs: update doxygen site from ${GITHUB_SHA}"
|
git commit -m "docs: update doxygen site from ${COMMIT_SHA}"
|
||||||
git push origin HEAD
|
git push origin HEAD
|
||||||
Reference in New Issue
Block a user