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
name: Vale linting | |
on: | |
pull_request: | |
types: [opened, synchronize, reopened] | |
paths: | |
- 'website/docs/**/*' | |
- 'website/blog/**/*' | |
- 'website/**/*' | |
jobs: | |
vale: | |
name: Vale linting | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
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 | |
- name: Get changed files | |
id: changed-files | |
uses: tj-actions/changed-files@v34 | |
with: | |
files: | | |
website/**/*.md | |
separator: ' ' | |
- name: Debugging - Print changed files | |
if: ${{ steps.changed-files.outputs.any_changed == 'true' }} | |
run: | | |
echo "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_and_modified_files }}; do | |
if [ -f "$file" ]; then | |
echo "Found: $file" | |
else | |
echo "File not found: $file" | |
exit 1 | |
fi | |
done | |
- name: Run Vale and report errors but don't fail | |
if: ${{ steps.changed-files.outputs.any_changed == 'true' }} | |
id: vale-lint | |
uses: errata-ai/vale-action@reviewdog | |
with: | |
token: ${{ secrets.GITHUB_TOKEN }} | |
reporter: github-check | |
level: error # Report as errors instead of warnings | |
fail_on_error: false # Ensure the check won't fail the entire CI | |
files: ${{ steps.changed-files.outputs.all_changed_and_modified_files }} | |
separator: ' ' | |
version: '2.27.0' | |
- name: Post comment if Vale finds errors | |
if: steps.vale-lint.outcome == 'success' | |
run: | | |
COMMENT="❗️Vale linting found errors! 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)" | |
gh pr comment ${{ github.event.pull_request.number }} --body "$COMMENT" | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |