-
Notifications
You must be signed in to change notification settings - Fork 977
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'test-vale' into test-vale-pr
- Loading branch information
Showing
1 changed file
with
18 additions
and
72 deletions.
There are no files selected for viewing
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
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 }} |