Skip to content

Commit

Permalink
chore: cancel build on Read the Docs conditionally (#406)
Browse files Browse the repository at this point in the history
  • Loading branch information
huxuan committed Mar 15, 2024
1 parent 51ed166 commit 1031389
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 0 deletions.
1 change: 1 addition & 0 deletions .github/workflows/readthedocs-preview.yml
Expand Up @@ -18,5 +18,6 @@ on:
- .readthedocs.yaml
- README.md
- docs/**
- pdm.lock
permissions:
pull-requests: write
9 changes: 9 additions & 0 deletions .readthedocs.yaml
Expand Up @@ -6,6 +6,15 @@ build:
post_checkout:
- env | sort
- git fetch --unshallow || true
# Cancel building pull requests when there aren't changed in the related files and folders.
# 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.
# Ref: https://docs.readthedocs.io/en/stable/build-customization.html#cancel-build-based-on-a-condition
- |
if [ "$READTHEDOCS_VERSION_TYPE" = "external" ] && git diff --quiet origin/main -- .github/workflows/readthedocs-preview.yml .readthedocs.yaml README.md docs/ pdm.lock;
then
exit 183;
fi
post_install:
- python -m pip install --upgrade --no-cache-dir pdm
- PDM_NO_EDITABLE=true make dev-doc
Expand Down
9 changes: 9 additions & 0 deletions template/.readthedocs.yaml
Expand Up @@ -6,6 +6,15 @@ build:
post_checkout:
- env | sort
- git fetch --unshallow || true
# Cancel building pull requests when there aren't changed in the related files and folders.
# 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.
# Ref: https://docs.readthedocs.io/en/stable/build-customization.html#cancel-build-based-on-a-condition
- |
if [ "$READTHEDOCS_VERSION_TYPE" = "external" ] && git diff --quiet origin/main -- .github/workflows/readthedocs-preview.yml .readthedocs.yaml README.md docs/ pdm.lock;
then
exit 183;
fi
post_install:
- python -m pip install --upgrade --no-cache-dir pdm
- PDM_NO_EDITABLE=true make dev-doc
Expand Down
Expand Up @@ -18,5 +18,6 @@ on:
- .readthedocs.yaml
- README.md
- docs/**
- pdm.lock
permissions:
pull-requests: write

0 comments on commit 1031389

Please sign in to comment.