Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
mirnawong1 committed Oct 15, 2024
1 parent 26fd03f commit 5c93ab2
Showing 1 changed file with 25 additions and 32 deletions.
57 changes: 25 additions & 32 deletions .github/workflows/vale.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,7 @@ jobs:
python-version: '3.x'

- name: Install Vale
run: pip install vale==2.27.0 # Install Vale

- name: Install Reviewdog
run: |
curl -sfL https://raw.githubusercontent.com/reviewdog/reviewdog/master/install.sh | sh -s -- -b /usr/local/bin/
run: pip install vale==2.27.0 # Install a stable version of Vale

- name: Get changed files
id: changed-files
Expand All @@ -47,13 +43,13 @@ jobs:
if: ${{ steps.changed-files.outputs.any_changed == 'true' }}
run: |
echo "Changed files:"
echo "${{ steps.changed-files.outputs.all_changed_files }}"
echo "${{ steps.changed-files.outputs.all_changed_and_modified_files }}"
- name: Confirm files exist
if: ${{ steps.changed-files.outputs.any_changed == 'true' }}
run: |
echo "Checking if files exist..."
for file in ${{ steps.changed-files.outputs.all_changed_files }}; do
for file in ${{ steps.changed-files.outputs.all_changed_and_modified_files }}; do
if [ -f "$file" ]; then
echo "Found: $file"
else
Expand All @@ -62,40 +58,37 @@ jobs:
fi
done
- name: Run Vale and capture output
- name: Run Vale with reviewdog
if: ${{ steps.changed-files.outputs.any_changed == 'true' }}
id: run-vale
run: |
# Run Vale and output results in JSON format
vale --output=JSON ${{ steps.changed-files.outputs.all_changed_files }} > vale_output.json
id: vale-lint
uses: errata-ai/vale-action@reviewdog
with:
token: ${{ secrets.GITHUB_TOKEN }}
reporter: github-check
files: ${{ steps.changed-files.outputs.all_changed_and_modified_files }}
separator: ' '
version: '2.27.0'

- name: Check for Vale issues
- name: Check Vale issues and set output
if: ${{ steps.changed-files.outputs.any_changed == 'true' }}
id: check_vale_issues
run: |
# Check if any warnings are present in the output
if grep -qi '"severity": *"warning"' vale_output.json; then
echo "issues_found=true" >> $GITHUB_OUTPUT
# Checking if reviewdog reported any issues
vale_issues=$(gh pr view ${{ github.event.pull_request.number }} --json comments --jq '.comments[].body' | grep 'reviewdog')
if [[ -n "$vale_issues" ]]; then
echo "Vale issues found!"
echo "::set-output name=vale_issues::true"
else
echo "issues_found=false" >> $GITHUB_OUTPUT
echo "No Vale issues found."
echo "::set-output name=vale_issues::false"
fi
- name: Run Reviewdog
if: ${{ steps.check_vale_issues.outputs.issues_found == 'true' }}
run: |
# Feed the Vale output to Reviewdog to create annotations
cat vale_output.json | reviewdog -f=rdjson -name=vale \
-reporter=github-pr-check -fail-on-error=false \
-filter-mode=added -level=warning
env:
REVIEWDOG_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Post summary comment
if: ${{ steps.check_vale_issues.outputs.issues_found == 'true' }}
- name: Post summary comment if issues found
if: ${{ steps.vale-lint.outputs.vale_issues == 'true' }}
run: |
COMMENT="❗️Oh no, some Vale linting issues were found! Please check the **Files changed** tab for detailed results and make the necessary updates."
COMMENT="❗️Oh no, some Vale linting found issues! Please check the **Files changed** tab for detailed results and make the necessary updates."
COMMENT+=$'\n'
COMMENT+=$'\n\n'
COMMENT+="➡️ [View detailed report](${{ github.event.pull_request.html_url }}/files)"
COMMENT+="➡️ Link to detailed report: [Files changed](${{ github.event.pull_request.html_url }}/files)"
gh pr comment ${{ github.event.pull_request.number }} --body "$COMMENT"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 comments on commit 5c93ab2

Please sign in to comment.