-
Notifications
You must be signed in to change notification settings - Fork 89
67 lines (57 loc) · 1.95 KB
/
check-styleguide.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
name: Check VTEX Styleguide
on:
pull_request:
types: [opened, synchronize]
jobs:
check-vtex-styleguide:
runs-on: ubuntu-latest
steps:
# Step 1: Check out the repository
- name: Check out code
uses: actions/checkout@v3
with:
fetch-depth: 0
# Step 2: Set up Node.js
- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: '18'
# Step 3: Install dependencies
- name: Install dependencies
run: npm install @actions/core@1.10
- name: Install Reviewdog
uses: reviewdog/action-setup@v1
# Step 4: Get all changed markdown files
- name: Get all changed markdown files
id: changed-markdown-files
uses: tj-actions/changed-files@v45
with:
files: |
**.md
**.mdx
# Step 5: Run style checker and collect issues
- name: Run style checker
id: style-check
if: steps.changed-markdown-files.outputs.any_changed == 'true'
run: |
> style_issues.txt
for file in ${{ steps.changed-markdown-files.outputs.all_changed_files }}; do
echo "Running styleguide checker on $file"
node .github/scripts/check-styleguide.js "./$file" >> style_issues.txt || true
done
if [ -s style_issues.txt ]; then
echo "style-issues=true" >> $GITHUB_ENV
fi
# Step 6: Run Reviewdog
- name: Run Reviewdog
if: env.style-issues == 'true'
run: |
echo "Running Reviewdog with the following style issues:"
cat style_issues.txt
reviewdog -efm="%f:%l:%c:%m" -name="style-check" -reporter=github-pr-review < style_issues.txt
env:
REVIEWDOG_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# Step 7: Fail the PR if there are style issues
- name: Fail PR if style issues
if: env.style-issues == 'true'
run: exit 1