|
5 | 5 | push:
|
6 | 6 | branches:
|
7 | 7 | - main
|
| 8 | + |
8 | 9 | jobs:
|
9 | 10 | pyspelling:
|
10 | 11 | runs-on: ubuntu-20.04
|
11 | 12 | steps:
|
12 |
| - - uses: actions/checkout@v3 |
| 13 | + - name: Check for skip label |
| 14 | + if: github.event_name == 'pull_request' |
| 15 | + id: skip-label |
| 16 | + uses: actions/github-script@v6 |
| 17 | + with: |
| 18 | + script: | |
| 19 | + const { data: labels } = await github.rest.issues.listLabelsOnIssue({ |
| 20 | + owner: context.repo.owner, |
| 21 | + repo: context.repo.repo, |
| 22 | + issue_number: context.issue.number |
| 23 | + }); |
| 24 | + const skipLabel = labels.find(label => label.name === 'skip-spell-check'); |
| 25 | + if (skipLabel) { |
| 26 | + console.log('Found skip-spell-check label, skipping spell check'); |
| 27 | + core.setOutput('skip', 'true'); |
| 28 | + } else { |
| 29 | + core.setOutput('skip', 'false'); |
| 30 | + } |
| 31 | +
|
| 32 | + - uses: actions/checkout@v4 |
| 33 | + if: github.event_name != 'pull_request' || steps.skip-label.outputs.skip != 'true' |
| 34 | + with: |
| 35 | + fetch-depth: 0 |
| 36 | + |
| 37 | + - name: Get changed files |
| 38 | + if: github.event_name != 'pull_request' || steps.skip-label.outputs.skip != 'true' |
| 39 | + id: changed-files |
| 40 | + run: | |
| 41 | + if [ "${{ github.event_name }}" == "pull_request" ]; then |
| 42 | + CHANGED_FILES=$(git diff --name-only origin/${{ github.base_ref }}..HEAD -- \ |
| 43 | + './*.{rst,md}' \ |
| 44 | + 'beginner_source/**/*.{py,rst,md}' \ |
| 45 | + 'intermediate_source/**/*.{py,rst,md}' \ |
| 46 | + 'advanced_source/**/*.{py,rst,md}' \ |
| 47 | + 'recipes_source/**/*.{py,rst,md}' \ |
| 48 | + 'prototype_source/**/*.{py,rst,md}') |
| 49 | + else |
| 50 | + CHANGED_FILES=$(git diff --name-only HEAD^..HEAD -- \ |
| 51 | + './*.{rst,md}' \ |
| 52 | + 'beginner_source/**/*.{py,rst,md}' \ |
| 53 | + 'intermediate_source/**/*.{py,rst,md}' \ |
| 54 | + 'advanced_source/**/*.{py,rst,md}' \ |
| 55 | + 'recipes_source/**/*.{py,rst,md}' \ |
| 56 | + 'prototype_source/**/*.{py,rst,md}') |
| 57 | + fi |
| 58 | + echo "files=$CHANGED_FILES" >> $GITHUB_OUTPUT |
| 59 | +
|
| 60 | + - name: Check if relevant files changed |
| 61 | + if: github.event_name != 'pull_request' || steps.skip-label.outputs.skip != 'true' |
| 62 | + id: check |
| 63 | + run: | |
| 64 | + if [ -z "${{ steps.changed-files.outputs.files }}" ]; then |
| 65 | + echo "skip=true" >> $GITHUB_OUTPUT |
| 66 | + echo "No relevant files changed in monitored directories, skipping spell check" |
| 67 | + else |
| 68 | + echo "skip=false" >> $GITHUB_OUTPUT |
| 69 | + echo "Found changed files to check:" |
| 70 | + echo "${{ steps.changed-files.outputs.files }}" |
| 71 | + fi |
| 72 | +
|
13 | 73 | - uses: actions/setup-python@v4
|
| 74 | + if: | |
| 75 | + (github.event_name != 'pull_request' || steps.skip-label.outputs.skip != 'true') && |
| 76 | + steps.check.outputs.skip != 'true' |
14 | 77 | with:
|
15 | 78 | python-version: '3.9'
|
16 | 79 | cache: 'pip'
|
17 |
| - - run: pip install pyspelling |
18 |
| - - run: sudo apt-get install aspell aspell-en |
19 |
| - - run: pyspelling |
20 | 80 |
|
| 81 | + - name: Install dependencies |
| 82 | + if: | |
| 83 | + (github.event_name != 'pull_request' || steps.skip-label.outputs.skip != 'true') && |
| 84 | + steps.check.outputs.skip != 'true' |
| 85 | + run: | |
| 86 | + pip install pyspelling |
| 87 | + sudo apt-get install aspell aspell-en |
| 88 | +
|
| 89 | + - name: Run pyspelling |
| 90 | + if: | |
| 91 | + (github.event_name != 'pull_request' || steps.skip-label.outputs.skip != 'true') && |
| 92 | + steps.check.outputs.skip != 'true' |
| 93 | + run: | |
| 94 | + pyspelling --source "${{ steps.changed-files.outputs.files }}" |
0 commit comments