|
3 | 3 | push:
|
4 | 4 | branches:
|
5 | 5 | - main
|
6 |
| - paths: |
7 |
| - - "docs/**" |
8 |
| - - "mkdocs.yml" |
9 |
| - - ".github/workflows/docs.yml" |
10 |
| - - "**/*.py" # Watch all Python files |
11 | 6 | pull_request:
|
12 | 7 | branches:
|
13 | 8 | - main
|
14 |
| - paths: |
15 |
| - - "docs/**" |
16 |
| - - "mkdocs.yml" |
17 |
| - - ".github/workflows/docs.yml" |
18 |
| - - "**/*.py" # Watch all Python files |
19 |
| - |
20 | 9 | permissions:
|
21 | 10 | contents: write
|
22 |
| - |
23 | 11 | jobs:
|
24 | 12 | Docs:
|
25 | 13 | runs-on: ubuntu-latest
|
26 | 14 | steps:
|
27 | 15 | - uses: actions/checkout@v4
|
28 |
| - with: |
29 |
| - fetch-depth: 0 # Fetch all history for comparing changes |
30 |
| - |
31 |
| - - name: Check for docstring changes |
32 |
| - id: check_changes |
33 |
| - run: | |
34 |
| - # Get the last two commits |
35 |
| - CHANGED_FILES=$(git diff --name-only HEAD^ HEAD) |
36 |
| -
|
37 |
| - # Check if docs files changed directly |
38 |
| - if echo "$CHANGED_FILES" | grep -q -E "^docs/|mkdocs.yml"; then |
39 |
| - echo "Direct documentation changes found" |
40 |
| - echo "should_deploy=true" >> $GITHUB_OUTPUT |
41 |
| - exit 0 |
42 |
| - fi |
43 |
| -
|
44 |
| - # Check Python files for docstring changes |
45 |
| - for file in $(echo "$CHANGED_FILES" | grep '\.py$'); do |
46 |
| - if [ -f "$file" ]; then |
47 |
| - if git diff HEAD^ HEAD "$file" | grep -q '^[+-][\t ]*['"'"'\"]\{3\}'; then |
48 |
| - echo "Docstring changes found in $file" |
49 |
| - echo "should_deploy=true" >> $GITHUB_OUTPUT |
50 |
| - exit 0 |
51 |
| - fi |
52 |
| - fi |
53 |
| - done |
54 |
| -
|
55 |
| - echo "No relevant changes found" |
56 |
| - echo "should_deploy=false" >> $GITHUB_OUTPUT |
57 |
| -
|
58 | 16 | - uses: actions/setup-python@v5
|
59 |
| - if: steps.check_changes.outputs.should_deploy == 'true' |
60 | 17 | with:
|
61 | 18 | python-version: 3.x
|
62 |
| - |
63 | 19 | - uses: actions/cache@v4
|
64 |
| - if: steps.check_changes.outputs.should_deploy == 'true' |
65 | 20 | with:
|
66 | 21 | key: ${{github.ref}}
|
67 | 22 | path: .cache
|
68 |
| - |
69 | 23 | - name: Install dependencies
|
70 |
| - if: steps.check_changes.outputs.should_deploy == 'true' |
71 | 24 | run: |
|
72 | 25 | python -m pip install --upgrade pip
|
73 | 26 | pip install mkdocs-material mkdocstrings-python mkdocs-include-markdown-plugin
|
74 |
| -
|
75 |
| - - name: Deploy docs |
76 |
| - if: steps.check_changes.outputs.should_deploy == 'true' |
77 |
| - run: mkdocs gh-deploy --force |
| 27 | + - run: mkdocs gh-deploy --force |
0 commit comments