Skip to content

Commit 6e85f2b

Browse files
ci: Fix doc update logic
1 parent 7b4b057 commit 6e85f2b

1 file changed

Lines changed: 36 additions & 5 deletions

File tree

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

Lines changed: 36 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ jobs:
4545
echo '<body>' >> ../original_docs/docs/html/version.html
4646
echo ' <h1>Documentation Version</h1>' >> ../original_docs/docs/html/version.html
4747
echo ' <p>Version: stable</p>' >> ../original_docs/docs/html/version.html
48-
echo ' <p>Branch: master</p>' >> index.html
48+
echo ' <p>Branch: master</p>' >> ../original_docs/docs/html/version.html
4949
echo " <p>Build Date: $(date -u)</p>" >> ../original_docs/docs/html/version.html
5050
echo " <p>Commit: ${{ github.sha }}</p>" >> ../original_docs/docs/html/version.html
5151
echo '</body>' >> ../original_docs/docs/html/version.html
@@ -64,12 +64,12 @@ jobs:
6464
6565
cd deploy-repo
6666
67-
# Only update stable directory
67+
# Update stable directory
6868
rm -rf stable
6969
mkdir -p stable
7070
cp -r ../../original_docs/docs/html/* stable/
7171
72-
# Create index.html redirection
72+
# Regenerate the main index.html to include the latest tag version
7373
echo '<!DOCTYPE html>' > index.html
7474
echo '<html>' >> index.html
7575
echo '<head>' >> index.html
@@ -82,16 +82,47 @@ jobs:
8282
echo ' <li><a href="stable/index.html">Stable (master branch)</a></li>' >> index.html
8383
echo ' <li><a href="latest/index.html">Latest (test branch)</a></li>' >> index.html
8484
echo ' <li><a href="versions/">Tag versions</a></li>' >> index.html
85+
echo ' </ul>' >> index.html
86+
echo ' <p>Recent tag versions:</p>' >> index.html
87+
echo ' <ul>' >> index.html
88+
89+
# Regenerate the list of recent tag versions (last 5)
90+
for dir in $(ls -1 versions/ 2>/dev/null | grep -E '^[0-9]+\.[0-9]+\.[0-9]+$' | sort -V -r | head -5); do
91+
echo " <li><a href=\"versions/$dir/index.html\">Version $dir</a></li>" >> index.html
92+
done
93+
8594
echo ' </ul>' >> index.html
8695
echo '</body>' >> index.html
8796
echo '</html>' >> index.html
8897
98+
# Also update versions/index.html to ensure that the list of all versions is up to date
99+
echo '<!DOCTYPE html>' > versions/index.html
100+
echo '<html>' >> versions/index.html
101+
echo '<head>' >> versions/index.html
102+
echo ' <title>Versioned Documentation</title>' >> versions/index.html
103+
echo '</head>' >> versions/index.html
104+
echo '<body>' >> versions/index.html
105+
echo ' <h1>Versioned Documentation</h1>' >> versions/index.html
106+
echo ' <p>Select a version:</p>' >> versions/index.html
107+
echo ' <ul>' >> versions/index.html
108+
109+
# List all versions (from newest to oldest)
110+
for dir in $(ls -1 versions/ 2>/dev/null | grep -E '^[0-9]+\.[0-9]+\.[0-9]+$' | sort -V -r); do
111+
echo " <li><a href=\"$dir/index.html\">Version $dir</a></li>" >> versions/index.html
112+
done
113+
114+
echo ' </ul>' >> versions/index.html
115+
echo ' <p><a href="../stable/index.html">Stable (master branch)</a></p>' >> versions/index.html
116+
echo ' <p><a href="../latest/index.html">Latest (test branch)</a></p>' >> versions/index.html
117+
echo '</body>' >> versions/index.html
118+
echo '</html>' >> versions/index.html
119+
89120
# Submit and push
90121
git add .
91122
if git diff-index --quiet HEAD --; then
92123
echo "No changes to deploy"
93124
else
94-
git commit -m "Deploy ${{ steps.version.outputs.docs-version }} documentation from ${{ github.sha }}"
125+
git commit -m "Deploy stable documentation from ${{ github.sha }} and update version lists"
95126
git push origin master
96-
echo "✅ Stable documentation deployed successfully"
127+
echo "✅ Stable documentation deployed successfully with updated version lists"
97128
fi

0 commit comments

Comments
 (0)