Skip to content

Commit 8c51ba0

Browse files
authored
CSHARP-5799: Implement api-docs redirection page to the latest version (#1833)
1 parent d06d817 commit 8c51ba0

File tree

1 file changed

+26
-2
lines changed

1 file changed

+26
-2
lines changed

evergreen/upload-apidocs.sh

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,40 @@
1-
#!/usr/bin/env bash
1+
#!/usr/bin/env bash
22
set -o errexit # Exit the script with error if any of the commands fail
33

44
DOCS_REPO="https://${GITHUB_USER}:${GITHUB_APIKEY}@github.com/mongodb/mongo-csharp-driver.git"
55

6-
echo "Prepare github docs"
6+
echo "Cloning github repo..."
77
git clone "$DOCS_REPO" ./gh-pages/ --branch gh-pages --single-branch
88

9+
echo "Adding the generated API-docs site..."
910
mkdir ./gh-pages/"$PACKAGE_VERSION"/
1011
cp -r ./artifacts/apidocs/"$PACKAGE_VERSION"/. ./gh-pages/"$PACKAGE_VERSION"/
1112

1213
cd ./gh-pages
1314

15+
echo "Generating redirection page..."
16+
# setup simple redirection to the latest version.
17+
18+
rm -f ./latest.html
19+
cat > "latest.html" << EOL
20+
<!DOCTYPE html>
21+
<html>
22+
<head>
23+
<title>Redirecting...</title>
24+
<meta charset="utf-8">
25+
<link rel="canonical" href="https://mongodb.github.io/mongo-csharp-driver/${PACKAGE_VERSION}/api/index.html" />
26+
<meta http-equiv="refresh" content="0; url=https://mongodb.github.io/mongo-csharp-driver/${PACKAGE_VERSION}/api/index.html" />
27+
</head>
28+
<body>
29+
<p>Redirecting you to the <a href="https://mongodb.github.io/mongo-csharp-driver/${PACKAGE_VERSION}/api/index.html">latest API Docs</a>...</p>
30+
</body>
31+
</html>
32+
33+
EOL
34+
35+
echo "Pushing the changes..."
1436
git add --all
1537
git commit -m "Add $PACKAGE_VERSION Api docs" --author="Build Agent<[email protected]>"
1638
git push --repo="$DOCS_REPO"
39+
40+
echo "Done."

0 commit comments

Comments
 (0)