Skip to content

Commit 22c8e37

Browse files
edit content-checks.yml to scan only files included in last commit
1 parent 0c94c0b commit 22c8e37

16 files changed

+581
-500
lines changed

.github/workflows/content-checks.yml

Lines changed: 80 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,43 +4,121 @@ on:
44
push:
55
branches:
66
- "**"
7+
paths:
8+
- "**/*.md"
9+
- "**/*.qmd"
710
pull_request:
11+
paths:
12+
- "**/*.md"
13+
- "**/*.qmd"
814

915
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+
1074
spell-check:
1175
name: Spell check (md/qmd)
1276
runs-on: ubuntu-latest
77+
needs: detect-changes
1378
steps:
1479
- name: Check out repository
1580
uses: actions/checkout@v4
1681

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+
1786
- name: Set up Python
87+
if: needs.detect-changes.outputs.files != ''
1888
uses: actions/setup-python@v5
1989
with:
2090
python-version: "3.x"
2191

2292
- name: Install codespell
93+
if: needs.detect-changes.outputs.files != ''
2394
run: python -m pip install --upgrade pip codespell
2495

2596
- name: Run codespell on .md and .qmd
97+
if: needs.detect-changes.outputs.files != ''
2698
run: |
27-
codespell --quiet-level=2 $(git ls-files '*.md' '*.qmd')
99+
codespell --quiet-level=2 ${{ needs.detect-changes.outputs.files }}
28100
29101
link-check:
30102
name: Link check (md/qmd)
31103
runs-on: ubuntu-latest
104+
needs: detect-changes
32105
steps:
33106
- name: Check out repository
34107
uses: actions/checkout@v4
35108

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+
36113
- name: Run lychee on .md and .qmd
37114
uses: lycheeverse/lychee-action@v1.10.0
115+
if: needs.detect-changes.outputs.files != ''
38116
with:
39117
args: >-
40118
--no-progress
41119
--verbose
42120
--accept 200,204,206
43121
--exclude-mail
44-
$(git ls-files '*.md' '*.qmd')
122+
${{ needs.detect-changes.outputs.files }}
45123
env:
46124
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
-10.4 KB
Binary file not shown.
-540 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)