From 569895f07580b66d5dbed0f1a357e55fe306ffcd Mon Sep 17 00:00:00 2001 From: Nathan Melehan Date: Fri, 23 Apr 2021 15:57:44 -0400 Subject: [PATCH] Vale GHA: filter out files that aren't inside docs/ directory - 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 --- .github/workflows/test.yaml | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 33ac3e24299..cb798cb1fb5 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -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/vale-action@v1.3.0 with: - files: '${{ steps.get_changed_files.outputs.added_modified }}' + files: '${{ steps.select_docs_dir_files.outputs.added_modified }}' env: GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}