diff --git a/.github/workflows/readthedocs-preview.yml b/.github/workflows/readthedocs-preview.yml index 110b4887..4a7d39e4 100644 --- a/.github/workflows/readthedocs-preview.yml +++ b/.github/workflows/readthedocs-preview.yml @@ -18,5 +18,6 @@ on: - .readthedocs.yaml - README.md - docs/** + - pdm.lock permissions: pull-requests: write diff --git a/.readthedocs.yaml b/.readthedocs.yaml index 929a6438..5207554f 100644 --- a/.readthedocs.yaml +++ b/.readthedocs.yaml @@ -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 -- README.md; + then + exit 183; + fi post_install: - python -m pip install --upgrade --no-cache-dir pdm - PDM_NO_EDITABLE=true make dev-doc diff --git a/copier.yaml b/copier.yaml index 0e08b316..45e5d83e 100644 --- a/copier.yaml +++ b/copier.yaml @@ -3,7 +3,7 @@ _envops: block_start_string: '[%' _subdirectory: template _message_before_copy: | - Thanks for generating a project using our template. + Thanks for generating a project using our template.1 You'll be asked a series of questions whose answers will be used to generate a tailored project for you. diff --git a/template/.readthedocs.yaml b/template/.readthedocs.yaml index 929a6438..5207554f 100644 --- a/template/.readthedocs.yaml +++ b/template/.readthedocs.yaml @@ -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 -- README.md; + then + exit 183; + fi post_install: - python -m pip install --upgrade --no-cache-dir pdm - PDM_NO_EDITABLE=true make dev-doc diff --git a/template/[% if repo_host_type == 'github.com' %].github[% endif %]/workflows/readthedocs-preview.yml.jinja b/template/[% if repo_host_type == 'github.com' %].github[% endif %]/workflows/readthedocs-preview.yml.jinja index 3a4545f2..e1883529 100644 --- a/template/[% if repo_host_type == 'github.com' %].github[% endif %]/workflows/readthedocs-preview.yml.jinja +++ b/template/[% if repo_host_type == 'github.com' %].github[% endif %]/workflows/readthedocs-preview.yml.jinja @@ -18,5 +18,6 @@ on: - .readthedocs.yaml - README.md - docs/** + - pdm.lock permissions: pull-requests: write