|
21 | 21 | pull_request: |
22 | 22 | paths: |
23 | 23 | - 'website/**' |
24 | | - - '**/*.md' |
25 | 24 |
|
26 | 25 | jobs: |
27 | | - lint-and-build: |
| 26 | + build-and-lint: |
28 | 27 | runs-on: ubuntu-latest |
29 | 28 | steps: |
30 | 29 | - name: Checkout code |
31 | 30 | uses: actions/checkout@v5 |
32 | 31 |
|
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 | | -
|
68 | 32 | - name: Setup pnpm |
69 | 33 | uses: pnpm/action-setup@v4 |
70 | 34 | with: |
71 | 35 | version: 8 |
72 | 36 | run_install: false |
73 | 37 |
|
| 38 | + - name: Setup Node.js |
| 39 | + uses: actions/setup-node@v4 |
| 40 | + with: |
| 41 | + node-version: '20' |
| 42 | + |
74 | 43 | - name: Enable corepack |
75 | 44 | working-directory: website |
76 | 45 | run: npm i -g --force corepack && corepack enable |
|
82 | 51 | - name: Build website |
83 | 52 | working-directory: website |
84 | 53 | 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