Skip to content

Commit a1df7dc

Browse files
committed
build_antora.sh: patch base-url with permalink
1 parent 83bc8d2 commit a1df7dc

File tree

2 files changed

+30
-1
lines changed

2 files changed

+30
-1
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,5 +123,5 @@ jobs:
123123
path: doc/html
124124

125125
- name: Deploy to GitHub Pages (jll63)
126-
if: matrix.os == 'ubuntu-latest' && github.repository_owner == 'jll63' && github.ref_name == 'feature/doc'
126+
if: matrix.os == 'ubuntu-latest' && github.repository_owner == 'jll63'
127127
uses: actions/deploy-pages@v4

doc/build_antora.sh

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
set -e
1313

14+
1415
if [ $# -eq 0 ]
1516
then
1617
echo "No playbook supplied, using default playbook"
@@ -22,6 +23,25 @@ fi
2223
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
2324
cd "$SCRIPT_DIR"
2425

26+
if [ -n "${CIRCLE_REPOSITORY_URL:-}" ]; then
27+
account="${CIRCLE_REPOSITORY_URL#*:}"
28+
account="${account%%/*}"
29+
lib=$(basename $(git rev-parse --show-toplevel))
30+
repository="${account}/$lib"
31+
sha=${CIRCLE_SHA1}
32+
elif [ -n "${GITHUB_REPOSITORY:-}" ]; then
33+
repository="${GITHUB_REPOSITORY}"
34+
sha=${GITHUB_SHA}
35+
fi
36+
37+
base_url="https://github.com/${repository}/blob/${sha}/"
38+
39+
if [ -n "${base_url}" ]; then
40+
echo "Setting base-url to $base_url"
41+
cp mrdocs.yml mrdocs.yml.bak
42+
perl -i -pe 's{^\s*base-url:.*$}{base-url: '"$base_url"'}' mrdocs.yml
43+
fi
44+
2545
echo "Building documentation with Antora..."
2646
echo "Installing npm dependencies..."
2747
npm ci
@@ -37,4 +57,13 @@ for f in $(find html -name '*.html'); do
3757
perl -i -pe 's{&lcub;&lcub;(.*?)&rcub;&rcub;}{<a href="../../../$1.html">$1</a>}g' "$f"
3858
done
3959

60+
if [ -n "${BASE_URL:-}" ]; then
61+
if [ -f mrdocs.yml.bak ]; then
62+
mv -f mrdocs.yml.bak mrdocs.yml
63+
echo "Restored original mrdocs.yml"
64+
else
65+
echo "mrdocs.yml.bak not found; skipping restore"
66+
fi
67+
fi
68+
4069
echo "Done"

0 commit comments

Comments
 (0)