[v1.x] ci: pick the docs toolchain per worktree in build-docs.sh
Backports main's toolchain-detecting scripts/build-docs.sh (from #3073) verbatim.
Motivation and Context
The combined Pages deploy builds both branches — v1.x at the site root and main under /v2/ — from whichever branch triggered the push. Once #3073 lands, main's half builds with Zensical, and this branch's hardcoded mkdocs build would fail every v1.x-triggered deploy. With the detection, each worktree is built with the toolchain its own files declare; v1.x keeps building with MkDocs via the fallback arm (which also owns its dependency sync).
Safe to merge before or after #3073: when main has no scripts/docs/build.sh yet, the detection falls back to the current MkDocs path for both halves.
How Has This Been Tested?
Both arms of this exact file were exercised on real builds for #3073: the Zensical arm in that PR's CI docs job and validation runs, the MkDocs fallback arm as the v1.x half of the combined-build verification.
Breaking Changes
None.
Types of changes
- Documentation update
Checklist
- I have read the MCP Documentation
- My code follows the repository's style guidelines
- New and existing tests pass locally