Skip to content

Commit c3204ed

Browse files
hugovksobolevnhumitosarhadthedev
authoredMay 24, 2023
RtD docs previews: Cancel building PRs if no changes in Doc dir (python#104100)
Co-authored-by: Nikita Sobolev <mail@sobolevn.me> Co-authored-by: Manuel Kaufmann <humitos@gmail.com> Co-authored-by: Oleg Iarygin <oleg@arhadthedev.net>
1 parent a5e0f5b commit c3204ed

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed
 

‎.readthedocs.yml

+14
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,20 @@ build:
1313
python: "3"
1414

1515
commands:
16+
# https://docs.readthedocs.io/en/stable/build-customization.html#cancel-build-based-on-a-condition
17+
#
18+
# Cancel building pull requests when there aren't changes in the Doc directory.
19+
#
20+
# If there are no changes (git diff exits with 0) we force the command to return with 183.
21+
# This is a special exit code on Read the Docs that will cancel the build immediately.
22+
- |
23+
if [ "$READTHEDOCS_VERSION_TYPE" = "external" ] && [ "$(git diff --quiet origin/main -- Doc/ .readthedocs.yml; echo $?)" -eq 0 ];
24+
then
25+
echo "No changes to Doc/ - exiting the build.";
26+
exit 183;
27+
fi
28+
1629
- make -C Doc venv html
1730
- mkdir _readthedocs
1831
- mv Doc/build/html _readthedocs/html
32+

‎Doc/tools/templates/layout.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
{%- if is_deployment_preview %}
1313
<div id="deployment-preview-warning" style="padding: .5em; text-align: center; background-color: #fff2ba; color: #6a580e;">
1414
{% trans %}This is a deploy preview created from a <a href="{{ repository_url }}/pull/{{ pr_id }}">pull request</a>.
15-
For authoritative documentation, see the {% endtrans %}
15+
For authoritative documentation, see {% endtrans %}
1616
<a href="https://docs.python.org/3/{{ pagename }}{{ file_suffix }}">{% trans %} the current stable release{% endtrans %}</a>.
1717
</div>
1818
{%- endif %}

0 commit comments

Comments
 (0)