diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index b246c1c..731dfe3 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -1,5 +1,8 @@ name: Deploy Docs to GitHub Pages +env: + FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true + on: push: branches: @@ -53,8 +56,13 @@ jobs: run: | set -euo pipefail - # Ensure both refs are available locally. - git fetch origin main dev + has_ref() { + git rev-parse --verify --quiet "$1" >/dev/null + } + + # Fetch refs separately (robust when one branch is not yet mirrored to GitHub). + git fetch origin main || true + git fetch origin dev || true MAIN_REF="origin/main" DEV_REF="origin/dev" @@ -65,21 +73,41 @@ jobs: DEV_REF="${SHA}" fi + if ! has_ref "${MAIN_REF}"; then + echo "::error::Konnte Main-Ref '${MAIN_REF}' nicht auflösen. Main-Doku kann nicht gebaut werden." + exit 1 + fi + if ! has_ref "${DEV_REF}"; then + echo "::warning::Dev-Ref '${DEV_REF}' nicht gefunden. Es wird ein Platzhalter unter /dev erzeugt." + DEV_REF="" + fi + # Build each branch in its own worktree and merge into one Pages artifact: # - main docs at site/ # - dev docs at site/dev/ rm -rf .worktrees site mkdir -p .worktrees git worktree add --detach .worktrees/main "${MAIN_REF}" - git worktree add --detach .worktrees/dev "${DEV_REF}" mkdocs build --strict --verbose \ --config-file .worktrees/main/mkdocs.yml \ --site-dir site - mkdocs build --strict --verbose \ - --config-file .worktrees/dev/mkdocs.yml \ - --site-dir site/dev + if [ -n "${DEV_REF}" ]; then + git worktree add --detach .worktrees/dev "${DEV_REF}" + mkdocs build --strict --verbose \ + --config-file .worktrees/dev/mkdocs.yml \ + --site-dir site/dev + else + mkdir -p site/dev + cat > site/dev/index.html <<'EOF' + + + Dev Doku +

Dev-Dokumentation ist aktuell auf GitHub noch nicht verfügbar.

+ + EOF + fi - name: Upload Pages artifact uses: actions/upload-pages-artifact@v3