-
Notifications
You must be signed in to change notification settings - Fork 983
85 lines (74 loc) · 2.73 KB
/
vale.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
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: 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-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'
- name: Check for Vale warnings
id: check-vale-warnings
run: |
vale_result=$(grep -c 'warning' <(cat /home/runner/reviewdog_issues.txt || true))
if [ "$vale_result" -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 }}