Skip to content

Docs: cancel PR builds if there is no documentation changes #9734

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Nov 22, 2022
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions .readthedocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,19 @@ build:
os: ubuntu-22.04
tools:
python: "3.10"
jobs:
post_checkout:
# https://docs.readthedocs.io/en/stable/build-customization.html#cancel-build-based-on-a-condition
#
# Cancel building pull requests when there aren't changed in the docs directory.
#
# If there are no changes (git diff exits with 0) we force the command to return with 183.
# This is a special exit code on Read the Docs that will cancel the build immediately.
- |
if [ "$READTHEDOCS_VERSION_TYPE" = "external" ] && git diff --quiet origin/main -- docs/;
then
exit 183;
fi

search:
ranking:
Expand Down
8 changes: 3 additions & 5 deletions docs/user/build-customization.rst
Original file line number Diff line number Diff line change
Expand Up @@ -140,15 +140,13 @@ Here is an example that cancels builds from pull requests when there are no chan
jobs:
post_checkout:
# Cancel building pull requests when there aren't changed in the docs directory.
# `--quiet` exits with a 1 when there **are** changes,
# so we invert the logic with a !
#
# If there are no changes (exit 0) we force the command to return with 183.
# If there are no changes (git diff exits with 0) we force the command to return with 183.
# This is a special exit code on Read the Docs that will cancel the build immediately.
- |
if [ $READTHEDOCS_VERSION_TYPE = "external" ];
if [ "$READTHEDOCS_VERSION_TYPE" = "external" ] && git diff --quiet origin/main -- docs/;
then
! git diff --quiet origin/main -- docs/ && exit 183;
exit 183;
fi


Expand Down