From 1754e917b0b59077eb67cb02dcc52371f0b0bc66 Mon Sep 17 00:00:00 2001 From: Georg Schramm <40211162+gschramm@users.noreply.github.com> Date: Fri, 15 Nov 2024 09:06:46 +0100 Subject: [PATCH] update workflows (#99) Co-authored-by: Georg Schramm --- .github/workflows/build_doc.yml | 11 ++++++++++- .github/workflows/rebuild_all_docs.yml | 12 ++++++++++-- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build_doc.yml b/.github/workflows/build_doc.yml index f2dcfbe3..497f2cf6 100644 --- a/.github/workflows/build_doc.yml +++ b/.github/workflows/build_doc.yml @@ -63,7 +63,7 @@ jobs: git checkout gh-pages # Determine redirect target - tagged_versions=$(ls _build/html | grep '^v') + tagged_versions=$(ls _build/html | grep '^v' || true) if [ -n "$tagged_versions" ]; then latest_tag=$(echo "$tagged_versions" | sort -V | tail -n 1) redirect_target="$latest_tag/index.html" @@ -71,6 +71,15 @@ jobs: redirect_target="master/index.html" fi + # Ensure _build/html directory exists + mkdir -p _build/html + + # Ensure index.html can be overwritten + if [ -f _build/html/index.html ]; then + echo "Overwriting existing _build/html/index.html" + rm _build/html/index.html + fi + # Create index.html for redirect echo '' > _build/html/index.html echo '' >> _build/html/index.html diff --git a/.github/workflows/rebuild_all_docs.yml b/.github/workflows/rebuild_all_docs.yml index 62ca46fe..677a73d7 100644 --- a/.github/workflows/rebuild_all_docs.yml +++ b/.github/workflows/rebuild_all_docs.yml @@ -25,13 +25,12 @@ jobs: run: sphinx-multiversion docs/source _build/html - name: Create index.html redirect - if: env.build_context != 'pr' run: | git fetch origin gh-pages git checkout gh-pages # Determine redirect target - tagged_versions=$(ls _build/html | grep '^v') + tagged_versions=$(ls _build/html | grep '^v' || true) if [ -n "$tagged_versions" ]; then latest_tag=$(echo "$tagged_versions" | sort -V | tail -n 1) redirect_target="$latest_tag/index.html" @@ -39,6 +38,15 @@ jobs: redirect_target="master/index.html" fi + # Ensure _build/html directory exists + mkdir -p _build/html + + # Ensure index.html can be overwritten + if [ -f _build/html/index.html ]; then + echo "Overwriting existing _build/html/index.html" + rm _build/html/index.html + fi + # Create index.html for redirect echo '' > _build/html/index.html echo '' >> _build/html/index.html