Skip to content

Commit 36522d8

Browse files
fix: cancel RTD builds on no change (ecmwf#97)
1 parent 0b5f8fb commit 36522d8

File tree

4 files changed

+34
-1
lines changed

4 files changed

+34
-1
lines changed

.github/workflows/readthedocs-pr-update.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ on:
88
# Execute this action only on PRs that touch
99
# documentation files.
1010
paths:
11+
- "**/.readthedocs.yaml"
1112
- "graphs/docs/**"
1213
- "models/docs/**"
1314
- "training/docs/**"
@@ -45,7 +46,6 @@ jobs:
4546
echo "training_changed=$(echo "$CHANGED_FILES" | grep -q '^training/' && echo 'true' || echo 'false')" >> $GITHUB_OUTPUT
4647
echo "graphs_changed=$(echo "$CHANGED_FILES" | grep -q '^graphs/' && echo 'true' || echo 'false')" >> $GITHUB_OUTPUT
4748
echo "models_changed=$(echo "$CHANGED_FILES" | grep -q '^models/' && echo 'true' || echo 'false')" >> $GITHUB_OUTPUT
48-
# echo "integration_changed=$(echo "$CHANGED_FILES" | grep -q '^tests/' && echo 'true' || echo 'false')" >> $GITHUB_OUTPUT
4949
5050
- name: Documentation for training package
5151
if: steps.changed-packages.outputs.training_changed == 'true'

graphs/.readthedocs.yaml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,17 @@ build:
44
os: ubuntu-22.04
55
tools:
66
python: "3.11"
7+
jobs:
8+
post_checkout:
9+
# Cancel building pull requests when there aren't changed in the docs directory or YAML file.
10+
#
11+
# If there are no changes (git diff exits with 0) we force the command to return with 183.
12+
# This is a special exit code on Read the Docs that will cancel the build immediately.
13+
- |
14+
if [ "$READTHEDOCS_VERSION_TYPE" = "external" ] && git diff --quiet origin/main -- graphs/docs/ graphs/.readthedocs.yaml;
15+
then
16+
exit 183;
17+
fi
718
819
sphinx:
920
configuration: graphs/docs/conf.py

models/.readthedocs.yaml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,17 @@ build:
44
os: ubuntu-22.04
55
tools:
66
python: "3.11"
7+
jobs:
8+
post_checkout:
9+
# Cancel building pull requests when there aren't changed in the docs directory or YAML file.
10+
#
11+
# If there are no changes (git diff exits with 0) we force the command to return with 183.
12+
# This is a special exit code on Read the Docs that will cancel the build immediately.
13+
- |
14+
if [ "$READTHEDOCS_VERSION_TYPE" = "external" ] && git diff --quiet origin/main -- models/docs/ models/.readthedocs.yaml;
15+
then
16+
exit 183;
17+
fi
718
819
sphinx:
920
configuration: models/docs/conf.py

training/.readthedocs.yaml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,17 @@ build:
44
os: ubuntu-22.04
55
tools:
66
python: "3.11"
7+
jobs:
8+
post_checkout:
9+
# Cancel building pull requests when there aren't changed in the docs directory or YAML file.
10+
#
11+
# If there are no changes (git diff exits with 0) we force the command to return with 183.
12+
# This is a special exit code on Read the Docs that will cancel the build immediately.
13+
- |
14+
if [ "$READTHEDOCS_VERSION_TYPE" = "external" ] && git diff --quiet origin/main -- training/docs/ training/.readthedocs.yaml;
15+
then
16+
exit 183;
17+
fi
718
819
sphinx:
920
configuration: training/docs/conf.py

0 commit comments

Comments
 (0)