diff --git a/.readthedocs.yaml b/.readthedocs.yaml index a3f84425605..acb2ab39df9 100644 --- a/.readthedocs.yaml +++ b/.readthedocs.yaml @@ -10,6 +10,22 @@ build: tools: python: "mambaforge-4.10" jobs: + post_checkout: + # Cancel building pull requests when there aren't changes related to docs. + # 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 -- \ + doc/ \ + pygmt/**/*.py \ + ':!pygmt/tests' \ + README.md \ + ci/requirements/docs.yml \ + .readthedocs.yaml; + then + exit 183; + fi pre_build: # Generate api stub files before building - make -C doc api