@@ -12,23 +12,38 @@ build:
1212 tools :
1313 python : " 3"
1414
15- commands :
16- # https://docs.readthedocs.io/en/stable/build-customization.html#cancel-build-based-on-a-condition
17- #
18- # Cancel building pull requests when there aren't changes in the Doc directory.
19- #
20- # If there are no changes (git diff exits with 0) we force the command to return with 183.
21- # This is a special exit code on Read the Docs that will cancel the build immediately.
22- - |
23- if [ "$READTHEDOCS_VERSION_TYPE" = "external" ] && [ "$(git diff --quiet origin/main -- Doc/ .readthedocs.yml; echo $?)" -eq 0 ];
24- then
25- echo "No changes to Doc/ - exiting the build.";
26- exit 183;
27- fi
28-
29- - asdf plugin add uv
30- - asdf install uv latest
31- - asdf global uv latest
32- - make -C Doc venv html
33- - mkdir _readthedocs
34- - mv Doc/build/html _readthedocs/html
15+ jobs :
16+ post_checkout :
17+ # https://docs.readthedocs.com/platform/stable/guides/build/skip-build.html#skip-builds-based-on-conditions
18+ #
19+ # Cancel building pull requests when there aren't changes in the Doc
20+ # directory or RTD configuration, or if we can't cleanly merge the base
21+ # branch.
22+ - |
23+ set -eux;
24+ if [ "$READTHEDOCS_VERSION_TYPE" = "external" ];
25+ then
26+ base_branch=main;
27+ git fetch --depth=1 origin $base_branch;
28+ if ! git merge --no-edit origin/$base_branch;
29+ then
30+ echo "Unsuccessful merge with '$base_branch' branch, skipping the build";
31+ exit 183;
32+ fi;
33+ if git diff --exit-code --stat origin/$base_branch -- Doc/ .readthedocs.yml;
34+ then
35+ echo "No changes to Doc/ - skipping the build.";
36+ exit 183;
37+ fi;
38+ fi;
39+ create_environment :
40+ - echo "Skipping default environment creation"
41+ install :
42+ - asdf plugin add uv
43+ - asdf install uv latest
44+ - asdf global uv latest
45+ build :
46+ html :
47+ - make -C Doc venv html
48+ - mkdir -p "$READTHEDOCS_OUTPUT"
49+ - mv Doc/build/html "$READTHEDOCS_OUTPUT/"
0 commit comments