Skip to content

Commit d1c7a8a

Browse files
authored
fix: Use GitHub Actions for markdown linting in ci-docs (#718)
1 parent 9944e2b commit d1c7a8a

File tree

1 file changed

+12
-37
lines changed

1 file changed

+12
-37
lines changed

.github/workflows/ci-docs.yml

Lines changed: 12 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -21,56 +21,25 @@ on:
2121
pull_request:
2222
paths:
2323
- 'website/**'
24-
- '**/*.md'
2524

2625
jobs:
27-
lint-and-build:
26+
build-and-lint:
2827
runs-on: ubuntu-latest
2928
steps:
3029
- name: Checkout code
3130
uses: actions/checkout@v5
3231

33-
- name: Setup Node.js
34-
uses: actions/setup-node@v4
35-
with:
36-
node-version: '20'
37-
38-
- name: Install markdownlint-cli2
39-
run: npm install -g markdownlint-cli2
40-
41-
- name: Run markdownlint
42-
id: lint
43-
run: |
44-
if [ "${{ github.event_name }}" = "pull_request" ]; then
45-
CHANGED_MD=$(git diff --name-only origin/${{ github.event.pull_request.base.ref }}...${{ github.event.pull_request.head.ref }} | grep -E '\.md$' || true)
46-
else
47-
CHANGED_MD=$(git diff-tree --no-commit-id --name-only -r ${{ github.sha }} | grep -E '\.md$' || true)
48-
fi
49-
if [ -n "$CHANGED_MD" ]; then
50-
markdownlint-cli2 "$CHANGED_MD" --config website/.markdownlint-cli2.jsonc > lint-result.txt || true
51-
if [ -s lint-result.txt ]; then
52-
echo "Lint failed."
53-
# Output non-compliant file contents to comment-body.txt
54-
for file in $CHANGED_MD; do
55-
echo "\n---\n**$file Content:**\n" >> comment-body.txt
56-
echo '\n```markdown' >> comment-body.txt
57-
cat "$file" >> comment-body.txt
58-
echo '\n```' >> comment-body.txt
59-
done
60-
echo "\n---\n**Lint Results:**\n" >> comment-body.txt
61-
cat lint-result.txt >> comment-body.txt
62-
exit 1
63-
fi
64-
else
65-
echo "No markdown files changed, skipping lint."
66-
fi
67-
6832
- name: Setup pnpm
6933
uses: pnpm/action-setup@v4
7034
with:
7135
version: 8
7236
run_install: false
7337

38+
- name: Setup Node.js
39+
uses: actions/setup-node@v4
40+
with:
41+
node-version: '20'
42+
7443
- name: Enable corepack
7544
working-directory: website
7645
run: npm i -g --force corepack && corepack enable
@@ -82,3 +51,9 @@ jobs:
8251
- name: Build website
8352
working-directory: website
8453
run: pnpm build
54+
55+
- name: Lint markdown files
56+
uses: DavidAnson/markdownlint-cli2-action@992badcdf24e3b8eb7e87ff9287fe931bcb00c6e
57+
with:
58+
globs: 'website/**/*.md'
59+
config: 'website/.markdownlint-cli2.jsonc'

0 commit comments

Comments
 (0)