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 9b7450a commit 69d8ae9
Showing 1 changed file with 32 additions and 24 deletions.
56 changes: 32 additions & 24 deletions .github/workflows/vale.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,22 @@ jobs:
with:
fetch-depth: 1

- name: List repository contents
run: |
pwd
ls -R
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.x'

- name: Install Vale
run: pip install vale==2.27.0 # Install a stable version of 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/
- name: Get changed files
id: changed-files
Expand All @@ -38,13 +47,13 @@ jobs:
if: ${{ steps.changed-files.outputs.any_changed == 'true' }}
run: |
echo "Changed files:"
echo "${{ steps.changed-files.outputs.all_changed_and_modified_files }}"
echo "${{ steps.changed-files.outputs.all_changed_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_and_modified_files }}; do
for file in ${{ steps.changed-files.outputs.all_changed_files }}; do
if [ -f "$file" ]; then
echo "Found: $file"
else
Expand All @@ -53,41 +62,40 @@ jobs:
fi
done
- name: Run Vale with Reviewdog
- name: Run Vale and capture output
if: ${{ steps.changed-files.outputs.any_changed == 'true' }}
id: run-vale
continue-on-error: true # Allow the workflow to continue even if this step fails
uses: errata-ai/vale-action@reviewdog
with:
token: ${{ secrets.GITHUB_TOKEN }}
reporter: github-pr-check
files: ${{ steps.changed-files.outputs.all_changed_and_modified_files }}
separator: ' '
version: '2.27.0'
fail_on_error: false
level: warning
debug: true
env:
REVIEWDOG_FLAGS: '-tee' # Output results to stdout
run: |
# Run Vale and output results in JSON format
vale --output=JSON ${{ steps.changed-files.outputs.all_changed_files }} > vale_output.json
- name: Check for Vale issues using grep
- name: Check for Vale issues
if: ${{ steps.changed-files.outputs.any_changed == 'true' }}
id: check_vale_issues
run: |
# Capture the logs of the previous step
grep_output=$(grep -E '"severity": "WARNING"' <<< "${{ steps.run-vale.outputs.output }}")
if [ -n "$grep_output" ]; then
# Check if any warnings are present in the output
if grep -q '"Severity":"warning"' vale_output.json; then
echo "issues_found=true" >> $GITHUB_OUTPUT
else
echo "issues_found=false" >> $GITHUB_OUTPUT
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.set_issues_found.outputs.issues_found == 'true' }}
if: ${{ steps.check_vale_issues.outputs.issues_found == 'true' }}
run: |
COMMENT="❗️Oh no, Vale found some linting issues! Please check the **Files changed** tab for detailed results and make the necessary updates."
COMMENT="❗️Oh no, some Vale linting issues were found! Please check the **Files changed** tab for detailed results and make the necessary updates."
COMMENT+=$'\n\n'
COMMENT+="➡️ Link to detailed report: [Files changed](${{ github.event.pull_request.html_url }}/files)"
COMMENT+="➡️ [View detailed report](${{ 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 69d8ae9

Please sign in to comment.