| 
1 |  | -name: Spell Check  | 
 | 1 | +name: Spellcheck PR Diff  | 
2 | 2 | 
 
  | 
3 | 3 | on:  | 
4 |  | -  # Switch from `pull_request_target` event to reduce distraction from comments  | 
5 |  | -  # regarding errors reported in unmodified files.  | 
6 | 4 |   pull_request:  | 
7 | 5 |     branches:  | 
8 | 6 |       - master  | 
9 |  | -    types:  | 
10 |  | -      - 'opened'  | 
11 |  | -      - 'reopened'  | 
12 |  | -      - 'synchronize'  | 
13 | 7 | 
 
  | 
14 | 8 | jobs:  | 
15 |  | -  spelling:  | 
16 |  | -    name: Spell Check  | 
17 |  | -    permissions:  | 
18 |  | -      contents: read  | 
19 |  | -      pull-requests: read  | 
20 |  | -      actions: read  | 
21 |  | -    outputs:  | 
22 |  | -      followup: ${{ steps.spelling.outputs.followup }}  | 
 | 9 | +  spellcheck:  | 
 | 10 | +    name: Spellcheck PR Diff  | 
23 | 11 |     runs-on: ubuntu-latest  | 
24 |  | -    if: "contains(github.event_name, 'pull_request') || github.event_name == 'push'"  | 
25 |  | -    concurrency:  | 
26 |  | -      group: spelling-${{ github.event.pull_request.number || github.ref }}  | 
27 |  | -      # note: If you use only_check_changed_files, you do not want cancel-in-progress  | 
28 |  | -      cancel-in-progress: true  | 
29 | 12 |     steps:  | 
30 |  | -    - name: Run Spellcheck  | 
31 |  | -      id: spelling  | 
32 |  | -      uses:  check-spelling/[email protected]  | 
33 |  | -      with:  | 
34 |  | -        # This workflow runs in response to both `push` and `pull_request`, if there's an open `pull_request` in the same repository  | 
35 |  | -        # for a given branch, there's no reason to spend resources checking both the `push` and the `pull_request`, so this flag tells  | 
36 |  | -        # the action while running for the `push` to find the `pull_request` and stop working early:  | 
37 |  | -        suppress_push_for_open_pull_request: 1  | 
38 |  | -        # The action will manage checking out the repository itself instead of requiring the workflow to use `actions/checkout...`:  | 
39 |  | -        #checkout: true  | 
40 |  | -        # If running without `: write`, posting a comment won't work, and for security `: write` permissions are left to a distinct  | 
41 |  | -        # (optional) job, here we skip trying to post a comment:  | 
42 |  | -        post_comment: 0  | 
43 |  | -        use_magic_file: 1  | 
44 |  | -        only_check_changed_files: true  | 
45 |  | -        extra_dictionary_limit: 10  | 
46 |  | -        extra_dictionaries:  | 
47 |  | -          cspell:software-terms/software-terms.txt  | 
48 |  | -          cspell:php/php.txt  | 
49 |  | -          cspell:node/node.txt  | 
50 |  | -          cspell:django/django.txt  | 
51 |  | -          cspell:html/html.txt  | 
52 |  | -          cspell:npm/npm.txt  | 
53 |  | -          cspell:ruby/ruby.txt  | 
54 |  | -          cspell:fullstack/fullstack.txt  | 
55 |  | -          cspell:filetypes/filetypes.txt  | 
56 |  | -        check_extra_dictionaries: ''  | 
57 |  | -        dictionary_source_prefixes: >-  | 
58 |  | -          {"cspell": "https://raw.githubusercontent.com/check-spelling/cspell-dicts/v20241114/dictionaries/"}  | 
 | 13 | +      - uses: actions/checkout@v4  | 
 | 14 | +        with:  | 
 | 15 | +          fetch-depth: 0  | 
 | 16 | + | 
 | 17 | +      - name: Install aspell  | 
 | 18 | +        run: sudo apt-get update && sudo apt-get install -y aspell  | 
 | 19 | + | 
 | 20 | +      - name: Run aspell on added lines  | 
 | 21 | +        run: |  | 
 | 22 | +          git fetch origin master  | 
 | 23 | +
  | 
 | 24 | +          git diff --unified=0 origin/master | \  | 
 | 25 | +          awk '  | 
 | 26 | +            BEGIN { filename=""; lineno=0 }  | 
 | 27 | +            /^diff --git/ {  | 
 | 28 | +              match($0, /^diff --git a\/.* b\/(.*)$/, m);  | 
 | 29 | +              filename = m[1];  | 
 | 30 | +            }  | 
 | 31 | +            /^\+\+\+/ { next }  | 
 | 32 | +            /^@@/ {  | 
 | 33 | +              match($0, /\+([0-9]+)/, m);  | 
 | 34 | +              lineno = m[1];  | 
 | 35 | +              next;  | 
 | 36 | +            }  | 
 | 37 | +            /^\+/ {  | 
 | 38 | +              text = substr($0, 2);  | 
 | 39 | +              cmd = "echo \"" text "\" | aspell --mode=none list --lang=en | sort -u";  | 
 | 40 | +              while ((cmd | getline word) > 0) {  | 
 | 41 | +                if (word != "") {  | 
 | 42 | +                  printf "::error file=%s,line=%d::Possible misspelling: %s\n", filename, lineno, word;  | 
 | 43 | +                }  | 
 | 44 | +              }  | 
 | 45 | +              close(cmd);  | 
 | 46 | +              lineno++;  | 
 | 47 | +            }  | 
 | 48 | +          '  | 
0 commit comments