@@ -2,49 +2,53 @@ name: Spell Check
22
33on :
44 pull_request :
5- paths :
6- - " **/*.md"
7- - " **/*.mdx"
8- - " **/*.txt"
9- - " **/*.yml"
10- - " **/*.yaml"
11- - " **/*.py"
12- - " **/*.js"
13- - " **/*.ts"
14- - " **/*.html"
15- - " **/*.rst"
16- - " !**/*.svg" # Exclude svg files from triggering the workflow
17- - " !**/*.sol"
18- - " **/*.go"
19- - " !**/*.sum"
20- - " !**/*.mod"
5+ types : [opened, synchronize, reopened, edited]
216
227jobs :
238 spell-check :
24- if : github.event.pull_request.changed_files > 0
259 runs-on : ubuntu-latest
26-
2710 steps :
2811 - name : Checkout code
2912 uses : actions/checkout@v4
13+ with :
14+ fetch-depth : 0 # Fetch all history for checking changes
15+
16+ - name : Get changed files
17+ id : changed-files
18+ run : |
19+ # Get list of changed files excluding binary and specific formats
20+ CHANGED_FILES=$(git diff --name-only --diff-filter=d origin/${{ github.base_ref }} HEAD | \
21+ grep -E '\.(md|mdx|txt|yml|yaml|py|js|ts|html|rst|go)$' | \
22+ grep -v -E '\.(svg|sol|sum|mod|png|jpg|woff|woff2|pdf|json)$' || true)
23+ echo "files=${CHANGED_FILES}" >> $GITHUB_OUTPUT
24+ echo "Changed files to check: ${CHANGED_FILES}"
3025
3126 - name : Set up Python
27+ if : steps.changed-files.outputs.files != ''
3228 uses : actions/setup-python@v5
3329 with :
3430 python-version : " 3.x"
3531
3632 - name : Install codespell
33+ if : steps.changed-files.outputs.files != ''
3734 run : pip install codespell
3835
3936 - name : Run Spell Check
37+ if : steps.changed-files.outputs.files != ''
4038 run : |
39+ # Create a temporary file with the list of files to check
40+ echo "${{ steps.changed-files.outputs.files }}" > files_to_check.txt
41+
42+ # Run codespell only on changed files
4143 codespell \
4244 --ignore-words=.github/config/ignored-words.txt \
43- --skip="*.svg,*.png,*.jpg,*.woff,*.woff2,*.pdf,*.json,package-lock.json" \
4445 --quiet-level=2 \
4546 --check-filenames \
46- .
47+ --files-with-matches \
48+ $(cat files_to_check.txt)
4749
48- - name : Annotate spelling errors
49- if : failure()
50- run : echo "::error::Spelling errors detected. Please fix the typos or add to the ignore list if intentional."
50+ - name : Skip message
51+ if : steps.changed-files.outputs.files == ''
52+ run : |
53+ echo "No relevant files were changed. Skipping spell check."
54+ exit 0
0 commit comments