Skip to content

Commit 91a4e51

Browse files
fix(readthedocs): dummy site for non PR builds (#317)
1 parent 207a363 commit 91a4e51

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

scripts/readthedocs_build.sh

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,32 @@ echo "github url: ${github_url}"
3232
echo "github user: ${github_user}"
3333
echo "github repo: ${github_repo}"
3434

35+
# For non PR builds, create a dummy index.html and exit early
36+
# ReadTheDocs sets READTHEDOCS_VERSION_TYPE to "external" for PR/external builds
37+
rtd_version_type="${READTHEDOCS_VERSION_TYPE:-}"
38+
echo "ReadTheDocs version type: ${rtd_version_type}"
39+
if [[ "${rtd_version_type}" != "external" ]]; then
40+
echo "Not a pull request build, creating dummy index.html"
41+
output_dir="${READTHEDOCS_OUTPUT}html"
42+
mkdir -p "${output_dir}"
43+
cat > "${output_dir}/index.html" <<'EOF'
44+
<!DOCTYPE html>
45+
<html lang="en">
46+
<head>
47+
<meta charset="UTF-8">
48+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
49+
<title>Preview not available</title>
50+
</head>
51+
<body>
52+
<h1>Preview not available</h1>
53+
<p>Previews are only generated for pull requests.</p>
54+
</body>
55+
</html>
56+
EOF
57+
echo "Dummy index.html written to ${output_dir}"
58+
exit 0
59+
fi
60+
3561
# set default directories
3662
project_dir="."
3763
theme_dir="."

0 commit comments

Comments
 (0)