test vale gha pr #68
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
name: Vale Lint | |
on: | |
pull_request: | |
paths: | |
- '**/*.md' | |
jobs: | |
vale: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 # Fetch all history so we can access all commits | |
- name: Install jq | |
run: sudo apt-get install -y jq | |
- name: Get changed files | |
id: changed-files | |
run: | | |
BASE_SHA=$(git merge-base origin/${{ github.event.pull_request.base.ref }} ${{ github.sha }}) | |
CHANGED_FILES=$(git diff --name-only $BASE_SHA ${{ github.sha }} -- '*.md') | |
echo "CHANGED_FILES=$CHANGED_FILES" >> $GITHUB_ENV | |
echo "::set-output name=files::$(echo $CHANGED_FILES | jq -R -s -c 'split("\n")[:-1]')" | |
- name: Print Changed Files | |
run: echo $CHANGED_FILES | |
- name: Install Vale | |
uses: errata-ai/vale-action@v2 | |
- name: Install Reviewdog | |
uses: reviewdog/action-setup@v1 | |
with: | |
reviewdog_version: latest | |
- name: Run Vale on changed files with Reviewdog | |
run: | | |
for file in $(echo ${{ steps.changed-files.outputs.files }} | jq -r '.[]'); do | |
vale --output=JSON $file > vale_output.json | |
cat vale_output.json | reviewdog -f=vale -name="Vale" -reporter=github-pr-review -level=warning -filter-mode=nofilter | |
done | |
env: | |
REVIEWDOG_GITHUB_API_TOKEN: ${{ secrets.REVIEWDOG_GITHUB_API_TOKEN }} | |
- name: Run Vale with code suggester | |
run: | | |
for file in $(echo ${{ steps.changed-files.outputs.files }} | jq -r '.[]'); do | |
vale --output=JSON $file > vale_output.json | |
jq '.[] | .file = "'$file'"' vale_output.json | jq -s . > rdjson_output.json | |
cat rdjson_output.json | reviewdog -f=rdjson -name="Vale" -reporter=github-pr-review -level=warning -filter-mode=nofilter | |
done | |
env: | |
REVIEWDOG_GITHUB_API_TOKEN: ${{ secrets.REVIEWDOG_GITHUB_API_TOKEN }} | |
- name: Run Reviewdog Suggestion Action | |
uses: reviewdog/action-suggester@v1 | |
with: | |
github_token: ${{ secrets.REVIEWDOG_GITHUB_API_TOKEN }} | |
tool_name: Vale | |
level: "warning" | |
filter_mode: "diff_context" | |
fail_on_error: "false" | |
reviewdog_flags: "" | |
cleanup: "true" |