Skip to content

Commit

Permalink
Vale GHA: filter out files that aren't inside docs/ directory
Browse files Browse the repository at this point in the history
- This helps avoid Vale running on non-content markdown files,
like our typography test page.
- A new select_docs_dir_files step is added. This step parses
and filters the JSON added_modified output from the
get_changed_files step. It then sets a new output for this
filtered file list that the Vale step later reads from.
- The jq command is used to filter the JSON list of files:
  https://stedolan.github.io/jq/
- This Stack Overflow served as inspiration:
  https://stackoverflow.com/questions/64482190/edit-the-value-inside-the-json-array-with-github-actions
  • Loading branch information
nmelehan committed May 10, 2021
1 parent c551efc commit 569895f
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,21 @@ jobs:
continue-on-error: true
with:
format: 'json'
- name: Install more-utils
run: sudo apt-get install moreutils
- name: Select Files in Docs Dir
id: select_docs_dir_files
run: |
docs_dir_files=$(echo $added_modified | jq -c '[.[] | select(.|test("^docs/"))]')
echo "::set-output name=added_modified::$docs_dir_files"
echo "Added or modified files located within docs/ directory:"
echo $docs_dir_files | jq '.'
env:
added_modified: ${{ steps.get_changed_files.outputs.added_modified }}
- name: Vale
uses: errata-ai/[email protected]
with:
files: '${{ steps.get_changed_files.outputs.added_modified }}'
files: '${{ steps.select_docs_dir_files.outputs.added_modified }}'
env:
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}

Expand Down

0 comments on commit 569895f

Please sign in to comment.