diff --git a/.github/workflows/vale.yml b/.github/workflows/vale.yml index 8137b819662..4ee1bb693cd 100644 --- a/.github/workflows/vale.yml +++ b/.github/workflows/vale.yml @@ -45,15 +45,40 @@ jobs: echo "Changed files:" echo "${{ steps.changed-files.outputs.all_changed_and_modified_files }}" - - name: Run Vale with reviewdog and show detailed annotations + - name: Run Vale with reviewdog if: ${{ steps.changed-files.outputs.any_changed == 'true' }} id: vale-lint uses: errata-ai/vale-action@reviewdog with: token: ${{ secrets.GITHUB_TOKEN }} - reporter: github-pr-annotations # Use GitHub PR check reporter for detailed annotations + reporter: github-pr-check # Use GitHub PR check reporter for detailed annotations level: warning # Flag warnings as issues filter_mode: added # Only analyze changed lines files: ${{ steps.changed-files.outputs.all_changed_and_modified_files }} separator: ' ' version: '2.27.0' + output: 'json' # Output the Vale results in JSON format for parsing + + - name: Check for Vale warnings + id: check-vale-warnings + run: | + if [[ $(jq '.warnings | length' < vale-output.json) -gt 0 ]]; then + echo "Vale found warnings or linting issues." + echo "has_warnings=true" >> $GITHUB_ENV + else + echo "No warnings or linting issues found." + echo "has_warnings=false" >> $GITHUB_ENV + fi + continue-on-error: true + + - name: Post comment if Vale finds issues + if: ${{ env.has_warnings == 'true' }} + run: | + COMMENT="❗️Oh no, some Vale linting found issues! Please check the **Files change** tab for detailed results and make the necessary updates." + COMMENT+=$'\n' + COMMENT+=$'\n\n' + 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 }} + has_warnings: ${{ env.has_warnings }}