Skip to content

Commit

Permalink
Merge branch 'test-vale' into test-vale-pr
Browse files Browse the repository at this point in the history
  • Loading branch information
mirnawong1 authored Jun 17, 2024
2 parents def6d29 + 0dc10ca commit e503fdc
Showing 1 changed file with 18 additions and 72 deletions.
90 changes: 18 additions & 72 deletions .github/workflows/vale.yml
Original file line number Diff line number Diff line change
@@ -1,85 +1,31 @@
name: Lint and Suggest
name: Reviewdog with Vale

on:
pull_request:
paths:
- '**/*.md'

permissions:
contents: read
pull-requests: write
on: [pull_request]

jobs:
vale:
reviewdog:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Check out code
uses: actions/checkout@v2

- name: Install Vale
uses: errata-ai/vale-action@v2
with:
version: latest

- 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: Run Vale on changed files
run: |
for file in $(echo ${{ steps.changed-files.outputs.files }} | jq -r '.[]'); do
echo "Running Vale on $file"
vale --output=JSON "$file" > "vale_output_${file//\//_}.json"
done
echo "Vale outputs:"
ls -l
- name: Apply Vale suggestions
run: |
mkdir -p suggested_changes
for file in $(echo ${{ steps.changed-files.outputs.files }} | jq -r '.[]'); do
vale --output=line "$file" | grep -oP 'Consider changing.*' > suggested_changes/"$(basename "$file")".suggestions
done
- name: Upload Vale results
uses: actions/upload-artifact@v3
with:
name: vale-results
path: '*.json'

- name: Upload suggested changes
uses: actions/upload-artifact@v3
with:
name: suggested-changes
path: suggested_changes/

suggest:
runs-on: ubuntu-latest
needs: vale

steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Download suggested changes
uses: actions/download-artifact@v3
with:
name: suggested-changes

- name: List downloaded files
run: ls -l suggested_changes
- name: Run Vale
run: vale --output=line .

- name: Suggest changes
uses: parkerbxyz/suggest-changes@v1
- name: Run Reviewdog
uses: reviewdog/action-reviewdog@v1
with:
comment: 'Please commit the suggested changes from Vale.'
github_token: ${{ secrets.REVIEWDOG_GITHUB_API_TOKEN }}
reporter: github-pr-review
filter_mode: diff_context
fail_on_error: false
level: warning
tool_name: vale
reviewdog_flags: "-f=rdjson"
env:
REVIEWDOG_GITHUB_API_TOKEN: ${{ secrets.REVIEWDOG_GITHUB_API_TOKEN }}

0 comments on commit e503fdc

Please sign in to comment.