Skip to content

Commit 485c6e9

Browse files
committed
ci: other strategy to fix deployment paths
1 parent b5f8eb7 commit 485c6e9

File tree

1 file changed

+41
-5
lines changed

1 file changed

+41
-5
lines changed

docs/make.jl

Lines changed: 41 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,43 @@ end
182182
# Run preprocessing on source files before makedocs()
183183
preprocess_source_index()
184184

185+
# Fix VitePress base path for dual deployment
186+
function fix_vitepress_base_path()
187+
deployment_target = get(ENV, "DEPLOYMENT_TARGET", "astroautomata")
188+
189+
# Determine the correct base path for each deployment
190+
base_path = if deployment_target == "cambridge"
191+
"/symbolicregression/dev/"
192+
else
193+
"/SymbolicRegression.jl/dev/"
194+
end
195+
196+
# Find and fix VitePress config files
197+
is_production = get(ENV, "DOCUMENTER_PRODUCTION", "false") == "true"
198+
build_subdir = is_production ? "1" : "."
199+
200+
config_paths = [
201+
joinpath(@__DIR__, "build", ".documenter", ".vitepress", "config.mts"),
202+
joinpath(@__DIR__, "build", build_subdir, ".vitepress", "config.mts"),
203+
]
204+
205+
for config_path in config_paths
206+
if isfile(config_path)
207+
@info "Fixing VitePress base path in $config_path for deployment target: $deployment_target"
208+
content = read(config_path, String)
209+
210+
# Replace the base path with the correct one for this deployment
211+
# Look for existing base: '...' patterns and replace them
212+
content = replace(content, r"base:\s*'[^']*'" => "base: '$base_path'")
213+
214+
write(config_path, content)
215+
@info "Updated VitePress base path to: $base_path"
216+
else
217+
@warn "VitePress config not found at: $config_path"
218+
end
219+
end
220+
end
221+
185222
# Configure deployment based on target
186223
deployment_target = get(ENV, "DEPLOYMENT_TARGET", "astroautomata")
187224

@@ -223,11 +260,7 @@ makedocs(;
223260
repo="github.com/MilesCranmer/SymbolicRegression.jl",
224261
devbranch="master",
225262
devurl="dev",
226-
deploy_url=if deployment_target == "cambridge"
227-
"https://ai.damtp.cam.ac.uk/symbolicregression"
228-
else
229-
"https://astroautomata.com/SymbolicRegression.jl"
230-
end,
263+
deploy_url=nothing, # Will be handled by post-processing
231264
deploy_decision,
232265
build_vitepress=get(ENV, "DOCUMENTER_PRODUCTION", "false") == "true",
233266
md_output_path=if get(ENV, "DOCUMENTER_PRODUCTION", "false") == "true"
@@ -257,6 +290,9 @@ makedocs(;
257290
# This runs after VitePress build to fix any final rendering issues
258291
post_process_vitepress_index()
259292

293+
# Fix VitePress base path for dual deployment
294+
fix_vitepress_base_path()
295+
260296
# Additional post-processing for VitePress production build issues
261297
function fix_vitepress_production_output()
262298
build_index_html = joinpath(@__DIR__, "build", "1", "index.html")

0 commit comments

Comments
 (0)