Skip to content

Commit 2aa56cf

Browse files
authored
Fix documentation deployment workflows to properly stage switcher.json changes. (#17)
- Update deploy-docs.yml: use git add -A for version directories, remove temporary push trigger - Update deploy-pr-docs.yml: add switcher.json propagation and fix git add commands - Add towncrier changelog fragment for issue #5
1 parent 05dd3b1 commit 2aa56cf

3 files changed

Lines changed: 34 additions & 21 deletions

File tree

.github/workflows/deploy-docs.yml

Lines changed: 6 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,16 @@ name: Deploy Documentation
22

33
on:
44
# Trigger after the test workflow completes successfully
5-
# workflow_run:
6-
# workflows: ["Unit Tests"]
7-
# types:
8-
# - completed
9-
# branches:
10-
# - main
5+
workflow_run:
6+
workflows: ["Unit Tests"]
7+
types:
8+
- completed
9+
branches:
10+
- main
1111

1212
# Allow manual deployment
1313
workflow_dispatch:
1414

15-
# Temporarily trigger on push for testing
16-
push:
17-
branches:
18-
- main
19-
2015
jobs:
2116
check-conditions:
2217
name: Check Deployment Conditions
@@ -38,13 +33,6 @@ jobs:
3833
exit 0
3934
fi
4035
41-
# Temporarily allow push events for testing
42-
if [[ "${{ github.event_name }}" == "push" ]]; then
43-
echo "✅ Conditions met: push to main (testing mode)"
44-
echo "should_deploy=true" >> $GITHUB_OUTPUT
45-
exit 0
46-
fi
47-
4836
# Check if triggered by successful push to main
4937
if [[ "${{ github.event.workflow_run.conclusion }}" == "success" && \
5038
"${{ github.event.workflow_run.event }}" == "push" ]]; then
@@ -84,7 +72,6 @@ jobs:
8472
- name: Install dependencies
8573
run: uv sync
8674

87-
# Temporarily skip coverage download when testing without workflow_run trigger
8875
- name: Download coverage artifact from test workflow
8976
if: github.event_name == 'workflow_run'
9077
# Download coverage artifact from the workflow_run that triggered this

.github/workflows/deploy-pr-docs.yml

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -187,10 +187,35 @@ jobs:
187187
mkdir -p "pr-${PR_NUMBER}/coverage"
188188
rsync -avr pr-source/tests/coverage/ "pr-${PR_NUMBER}/coverage/"
189189
fi
190+
191+
# Update switcher.json in all version directories
192+
# This ensures all versions have the latest switcher with all available versions
193+
echo "Updating switcher.json in all version directories..."
194+
for dir in */; do
195+
# Only process directories that look like version directories (X.Y.Z, latest, pr-N)
196+
# Skip: _build, docs, nexusLIMS (source code), and hidden dirs
197+
if [ -d "$dir" ] && [ "$dir" != "_build/" ] && \
198+
[ "$dir" != "docs/" ] && [ "$dir" != "nexusLIMS/" ] && \
199+
[[ ! "$dir" =~ ^\. ]]; then
200+
# Check if this looks like a docs directory (has _static subdirectory)
201+
dir_clean="${dir%/}"
202+
if [ -d "$dir_clean/_static" ]; then
203+
mkdir -p "$dir_clean/_static"
204+
cp pr-source/docs/_static/switcher.json "$dir_clean/_static/switcher.json"
205+
echo " Updated switcher.json in $dir"
206+
fi
207+
fi
208+
done
209+
190210
git config user.name "github-actions[bot]"
191211
git config user.email "github-actions[bot]@users.noreply.github.com"
192-
git add "pr-${PR_NUMBER}"
193-
git commit -m "Deploy docs preview for PR #${PR_NUMBER}" || echo "No changes to commit"
212+
213+
# Commit and push - add all changes in documentation directories
214+
git add -A "pr-${PR_NUMBER}/" 2>/dev/null || true
215+
git add -A latest/ 2>/dev/null || true
216+
git add -A [0-9]*/ 2>/dev/null || true
217+
git add -A pr-*/ 2>/dev/null || true
218+
git commit -m "Deploy docs preview for PR #${PR_NUMBER} and update switcher.json" || echo "No changes to commit"
194219
git pull --rebase origin gh-pages
195220
git push origin gh-pages
196221
echo "✅ Documentation preview deployed!"

docs/changes/5.misc.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fixed documentation version switcher to use full semantic version numbers (e.g., ``2.1.0``) instead of major.minor versions (e.g., ``2.1``), and properly highlight the current version being viewed. The switcher now shows only the most recent patch version for each minor release and marks the highest version as stable.

0 commit comments

Comments
 (0)