Update community.rst #318
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |