Skip to content

Commit cbf7985

Browse files
committed
🎨🧪 Convert doc.yml workflow to be reusable
This patch is meant to simplify the maintenance of multiple complex workflow definitions that are tied together into a single workflow later on.
1 parent ce2383e commit cbf7985

File tree

2 files changed

+26
-24
lines changed

2 files changed

+26
-24
lines changed

.github/workflows/build.yml

+24-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ permissions:
2626
contents: read
2727

2828
concurrency:
29-
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
29+
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}-reusable
3030
cancel-in-progress: true
3131

3232
jobs:
@@ -35,6 +35,7 @@ jobs:
3535
runs-on: ubuntu-latest
3636
timeout-minutes: 10
3737
outputs:
38+
run-docs: ${{ steps.docs-changes.outputs.run-docs || false }}
3839
run_tests: ${{ steps.check.outputs.run_tests }}
3940
steps:
4041
- uses: actions/checkout@v3
@@ -60,6 +61,28 @@ jobs:
6061
# https://github.com/python/core-workflow/issues/373
6162
git diff --name-only origin/$GITHUB_BASE_REF.. | grep -qvE '(\.rst$|^Doc|^Misc)' && echo "run_tests=true" >> $GITHUB_OUTPUT || true
6263
fi
64+
- name: Get a list of the changed documentation-related files
65+
if: github.event_name == 'pull_request'
66+
id: changed-docs-files
67+
uses: Ana06/[email protected]
68+
with:
69+
filter: |
70+
Doc/**
71+
Misc/**
72+
.github/workflows/reusable-docs.yml
73+
- name: Check for docs changes
74+
if: >-
75+
github.event_name == 'pull_request'
76+
&& steps.changed-docs-files.outputs.added_modified_renamed != ''
77+
id: docs-changes
78+
run: |
79+
echo "run-docs=true" >> "${GITHUB_OUTPUT}"
80+
81+
check-docs:
82+
name: 📝
83+
needs: check_source
84+
if: fromJSON(needs.check_source.outputs.run-docs)
85+
uses: ./.github/workflows/reusable-docs.yml
6386

6487
check_generated_files:
6588
name: 'Check if generated files are up to date'

.github/workflows/doc.yml renamed to .github/workflows/reusable-docs.yml

+2-23
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,8 @@
1-
name: Docs
1+
name: 📝
22

33
on:
4+
workflow_call:
45
workflow_dispatch:
5-
#push:
6-
# branches:
7-
# - 'main'
8-
# - '3.11'
9-
# - '3.10'
10-
# - '3.9'
11-
# - '3.8'
12-
# - '3.7'
13-
# paths:
14-
# - 'Doc/**'
15-
pull_request:
16-
branches:
17-
- 'main'
18-
- '3.11'
19-
- '3.10'
20-
- '3.9'
21-
- '3.8'
22-
- '3.7'
23-
paths:
24-
- 'Doc/**'
25-
- 'Misc/**'
26-
- '.github/workflows/doc.yml'
276

287
permissions:
298
contents: read

0 commit comments

Comments
 (0)