Skip to content

Commit 5dbbed5

Browse files
committed
ci update
1 parent 4cb2574 commit 5dbbed5

1 file changed

Lines changed: 35 additions & 16 deletions

File tree

.github/workflows/sphinx-build.yml

Lines changed: 35 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ jobs:
3232
echo "OUTPUT_FOLDER=${OUTPUT_FOLDER}" >> $GITHUB_ENV
3333
3434
- name: Set up Python
35-
uses: actions/setup-python@v2
35+
uses: actions/setup-python@v5
3636
with:
3737
python-version: 3.12
3838

@@ -43,34 +43,53 @@ jobs:
4343
4444
- name: Build Documentation for all branches
4545
run: |
46-
# Get array of all branches in origin
46+
OUTPUT_FOLDER="docs/_build"
47+
failed_branches=()
48+
4749
branches=($(git ls-remote --heads origin | cut -f2 | cut -d'/' -f3))
4850
49-
# iterate over all branches
5051
for branch in "${branches[@]}"; do
51-
# Print branch name
5252
echo "Building documentation for: $branch"
53+
git fetch origin "$branch"
54+
git checkout "$branch"
5355
54-
# Fetch and checkout branch
55-
git fetch origin $branch
56-
git checkout $branch
57-
58-
# Reinstall dependencies for each branch
56+
python -m venv ".venv-${branch}"
57+
source ".venv-${branch}/bin/activate"
58+
pip install --upgrade pip
5959
pip install -r requirements.txt
60+
deactivate
6061
61-
# main branch gets built in the root folder
6262
if [ "$branch" == "main" ]; then
63-
sphinx-build -b html source "${OUTPUT_FOLDER}"
63+
target="${OUTPUT_FOLDER}"
6464
else
65-
# Every other branch gets built in a subfolder
66-
mkdir -p "${OUTPUT_FOLDER}/$branch"
67-
sphinx-build -b html source "${OUTPUT_FOLDER}/$branch"
65+
target="${OUTPUT_FOLDER}/${branch}"
66+
mkdir -p "$target"
67+
fi
68+
69+
# Run sphinx but don't let it kill the loop
70+
if ! ".venv-${branch}/bin/sphinx-build" -b html source "$target"; then
71+
echo "::warning::Documentation build failed for branch: $branch"
72+
failed_branches+=("$branch")
73+
# Clean up partial output so a broken build isn't deployed
74+
rm -rf "$target"
6875
fi
6976
done
7077
71-
# Create .nojekyll file to prevent GitHub Pages from ignoring files/folders starting with an underscore
7278
touch "${OUTPUT_FOLDER}/.nojekyll"
7379
80+
# Fail the step after all branches are attempted, but only
81+
# if the *current* branch (the one that triggered this run) failed
82+
for branch in "${failed_branches[@]}"; do
83+
if [ "$branch" == "${{ github.ref_name }}" ]; then
84+
echo "::error::The triggering branch '$branch' failed to build."
85+
exit 1
86+
fi
87+
done
88+
89+
# Warn about other failures but don't block deployment
90+
if [ ${#failed_branches[@]} -gt 0 ]; then
91+
echo "::warning::Some branches failed to build: ${failed_branches[*]}"
92+
fi
7493
7594
7695
# echo "::set-output name=docs_folder::${OUTPUT_FOLDER}" # Set output for deploy job
@@ -83,7 +102,7 @@ jobs:
83102
deploy:
84103
environment:
85104
name: github-pages
86-
url: ${{ steps.build.outputs.url }}
105+
url: ${{ steps.deployment.outputs.page_url }}
87106
runs-on: ubuntu-latest
88107
needs: build
89108
steps:

0 commit comments

Comments
 (0)