|
4 | 4 | push: |
5 | 5 | branches: |
6 | 6 | - "**" |
| 7 | + paths: |
| 8 | + - "**/*.md" |
| 9 | + - "**/*.qmd" |
7 | 10 | pull_request: |
| 11 | + paths: |
| 12 | + - "**/*.md" |
| 13 | + - "**/*.qmd" |
8 | 14 |
|
9 | 15 | jobs: |
| 16 | + detect-changes: |
| 17 | + name: Detect changed content files |
| 18 | + runs-on: ubuntu-latest |
| 19 | + outputs: |
| 20 | + files: ${{ steps.changed-files.outputs.files }} |
| 21 | + steps: |
| 22 | + - name: Check out repository |
| 23 | + uses: actions/checkout@v4 |
| 24 | + with: |
| 25 | + fetch-depth: 0 |
| 26 | + |
| 27 | + - name: Collect changed markdown/quarto files |
| 28 | + id: changed-files |
| 29 | + shell: bash |
| 30 | + run: | |
| 31 | + if [[ "${{ github.event_name }}" == "pull_request" ]]; then |
| 32 | + base="${{ github.event.pull_request.base.sha }}" |
| 33 | + head="${{ github.event.pull_request.head.sha }}" |
| 34 | + else |
| 35 | + base="${{ github.event.before }}" |
| 36 | + head="${{ github.sha }}" |
| 37 | + fi |
| 38 | +
|
| 39 | + changed_files=$(git diff --name-only "$base" "$head" -- '*.md' '*.qmd' | tr '\n' ' ') |
| 40 | + echo "files=$changed_files" >> "$GITHUB_OUTPUT" |
| 41 | +
|
| 42 | + - name: Log changed files |
| 43 | + if: steps.changed-files.outputs.files != '' |
| 44 | + run: | |
| 45 | + echo "Changed .md/.qmd files:" |
| 46 | + printf '%s\n' ${{ steps.changed-files.outputs.files }} |
| 47 | +
|
| 48 | + - name: Job summary |
| 49 | + if: steps.changed-files.outputs.files != '' |
| 50 | + run: | |
| 51 | + { |
| 52 | + echo "## Changed content files" |
| 53 | + echo |
| 54 | + echo "Base: ${{ github.event.pull_request.base.sha || github.event.before }}" |
| 55 | + echo "Head: ${{ github.event.pull_request.head.sha || github.sha }}" |
| 56 | + echo |
| 57 | + for file in ${{ steps.changed-files.outputs.files }}; do |
| 58 | + echo "- $file" |
| 59 | + done |
| 60 | + } >> "$GITHUB_STEP_SUMMARY" |
| 61 | +
|
| 62 | + - name: Job summary (no changes) |
| 63 | + if: steps.changed-files.outputs.files == '' |
| 64 | + run: | |
| 65 | + { |
| 66 | + echo "## Changed content files" |
| 67 | + echo |
| 68 | + echo "Base: ${{ github.event.pull_request.base.sha || github.event.before }}" |
| 69 | + echo "Head: ${{ github.event.pull_request.head.sha || github.sha }}" |
| 70 | + echo |
| 71 | + echo "No .md/.qmd files changed in this commit/PR." |
| 72 | + } >> "$GITHUB_STEP_SUMMARY" |
| 73 | +
|
10 | 74 | spell-check: |
11 | 75 | name: Spell check (md/qmd) |
12 | 76 | runs-on: ubuntu-latest |
| 77 | + needs: detect-changes |
13 | 78 | steps: |
14 | 79 | - name: Check out repository |
15 | 80 | uses: actions/checkout@v4 |
16 | 81 |
|
| 82 | + - name: Skip notice (no md/qmd changes) |
| 83 | + if: needs.detect-changes.outputs.files == '' |
| 84 | + run: echo "No .md/.qmd files changed; skipping spell check." |
| 85 | + |
17 | 86 | - name: Set up Python |
| 87 | + if: needs.detect-changes.outputs.files != '' |
18 | 88 | uses: actions/setup-python@v5 |
19 | 89 | with: |
20 | 90 | python-version: "3.x" |
21 | 91 |
|
22 | 92 | - name: Install codespell |
| 93 | + if: needs.detect-changes.outputs.files != '' |
23 | 94 | run: python -m pip install --upgrade pip codespell |
24 | 95 |
|
25 | 96 | - name: Run codespell on .md and .qmd |
| 97 | + if: needs.detect-changes.outputs.files != '' |
26 | 98 | run: | |
27 | | - codespell --quiet-level=2 $(git ls-files '*.md' '*.qmd') |
| 99 | + codespell --quiet-level=2 ${{ needs.detect-changes.outputs.files }} |
28 | 100 |
|
29 | 101 | link-check: |
30 | 102 | name: Link check (md/qmd) |
31 | 103 | runs-on: ubuntu-latest |
| 104 | + needs: detect-changes |
32 | 105 | steps: |
33 | 106 | - name: Check out repository |
34 | 107 | uses: actions/checkout@v4 |
35 | 108 |
|
| 109 | + - name: Skip notice (no md/qmd changes) |
| 110 | + if: needs.detect-changes.outputs.files == '' |
| 111 | + run: echo "No .md/.qmd files changed; skipping link check." |
| 112 | + |
36 | 113 | - name: Run lychee on .md and .qmd |
37 | 114 | uses: lycheeverse/lychee-action@v1.10.0 |
| 115 | + if: needs.detect-changes.outputs.files != '' |
38 | 116 | with: |
39 | 117 | args: >- |
40 | 118 | --no-progress |
41 | 119 | --verbose |
42 | 120 | --accept 200,204,206 |
43 | 121 | --exclude-mail |
44 | | - $(git ls-files '*.md' '*.qmd') |
| 122 | + ${{ needs.detect-changes.outputs.files }} |
45 | 123 | env: |
46 | 124 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
0 commit comments