-
-
Notifications
You must be signed in to change notification settings - Fork 35
75 lines (61 loc) · 2.19 KB
/
linting.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
The workflow is currently configured to check the entire `docs` folder, which can be time-consuming and unnecessary when only a few files are modified in a pull request. Instead, you can modify the workflow to check only the files changed in the PR. Here's how to fix it:
1. **Use `paths` filter**: This will limit the workflow to run only when files in specific paths are changed.
2. **Use environment variables**: Set up environment variables to capture the changed files.
3. **Modify the Vale step**: Adjust the Vale step to process only the changed files.
Here is the updated workflow with the necessary changes:
```yaml
name: Linting
on:
pull_request:
paths:
- 'docs/**'
jobs:
prose:
runs-on: ubuntu-22.04 # See https://github.com/errata-ai/vale-action/issues/128 before upgrading
permissions:
contents: read
pull-requests: write
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-python@v4
with:
python-version: '3.x'
cache: 'pip'
- name: Install Python dependencies
run: pip3 install -r docs/requirements.txt
- name: Get changed files
id: changed-files
run: |
echo "::set-output name=files::$(git diff --name-only ${{ github.base_ref }} ${{ github.head_ref }} | grep '^docs/')"
- name: Vale
uses: errata-ai/vale-action@reviewdog
with:
filter_mode: added
version: 3.7.1
files: ${{ steps.changed-files.outputs.files }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- uses: actions/setup-python@v4
with:
python-version: '3.x'
cache: 'pip'
- name: Install Python dependencies
run: pip3 install -r docs/requirements.txt
- name: Build docs
working-directory: docs
run: make html
- name: Check links
working-directory: docs
run: make checklinks
```
This updates the workflow to:
- Run only when files in the `docs` directory are changed.
- Capture the changed files and pass them to the Vale action, ensuring only those files are checked.