Skip to content

Commit cd06519

Browse files
committed
Docs: cancel PR builds if there is no documentation changes
Use the new feature to cancel builds if there are not documentation changes
1 parent 38e346e commit cd06519

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

.readthedocs.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,21 @@ build:
1414
os: ubuntu-22.04
1515
tools:
1616
python: "3.10"
17+
jobs:
18+
post_checkout:
19+
# https://docs.readthedocs.io/en/stable/build-customization.html#cancel-build-based-on-a-condition
20+
#
21+
# Cancel building pull requests when there aren't changed in the docs directory.
22+
# `--quiet` exits with a 1 when there **are** changes,
23+
# so we invert the logic with a !
24+
#
25+
# If there are no changes (exit 0) we force the command to return with 183.
26+
# This is a special exit code on Read the Docs that will cancel the build immediately.
27+
- |
28+
if [ $READTHEDOCS_VERSION_TYPE = "external" ];
29+
then
30+
! git diff --quiet origin/main -- docs/ && exit 183;
31+
fi
1732
1833
search:
1934
ranking:

0 commit comments

Comments
 (0)