1- name : Markdown
2-
3- on : pull_request
4-
5- # Allow this job to clone the repo
6- permissions :
7- contents : read
8- id-token : write
9-
10- concurrency :
11- group : ${{ github.workflow }}-${{ github.ref }}
12- cancel-in-progress : true
13-
14- jobs :
15- lint :
16- runs-on : ubuntu-latest
17- strategy :
18- fail-fast : true
19-
20- steps :
21- - name : Checkout
22- uses : actions/checkout@v4
23- with :
24- fetch-depth : 0 # Fetch all history for comparison
25-
26- - name : Get changed markdown files
27- id : changed-files
28- run : |
29- # Fetch the base branch
30- git fetch origin ${{ github.base_ref }}
31-
32- # Get changed .md and .mdx files
33- CHANGED_FILES=$(git diff --name-only --diff-filter=ACMRT origin/${{ github.base_ref }}...HEAD | grep -E '\.(md|mdx)$' || true)
34-
35- # Store the files
36- echo "files<<EOF" >> $GITHUB_OUTPUT
37- echo "$CHANGED_FILES" >> $GITHUB_OUTPUT
38- echo "EOF" >> $GITHUB_OUTPUT
39-
40- # Count files
41- if [ -z "$CHANGED_FILES" ]; then
42- echo "count=0" >> $GITHUB_OUTPUT
43- else
44- echo "count=$(echo "$CHANGED_FILES" | wc -l)" >> $GITHUB_OUTPUT
45- fi
46-
47- - name : Install pnpm
48- if : steps.changed-files.outputs.count > 0
49- uses : pnpm/action-setup@v4
50- with :
51- version : 10.13.1
52- run_install : false
53-
54- - name : Setup Node
55- if : steps.changed-files.outputs.count > 0
56- uses : actions/setup-node@v4
57- with :
58- node-version : 20
59- cache : ' pnpm'
60- cache-dependency-path : ' pnpm-lock.yaml'
61-
62- - name : Get pnpm store directory
63- if : steps.changed-files.outputs.count > 0
64- shell : bash
65- run : |
66- echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
67-
68- - uses : actions/cache@v3
69- if : steps.changed-files.outputs.count > 0
70- name : Setup pnpm cache
71- with :
72- path : ${{ env.STORE_PATH }}
73- key : ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
74- restore-keys : |
75- ${{ runner.os }}-pnpm-store-
76-
77- - name : PNPM install
78- if : steps.changed-files.outputs.count > 0
79- run : |
80- echo; echo "cd to workspace"
81- cd $GITHUB_WORKSPACE
82- echo; echo "listing"
83- ls
84- echo; echo "PNPM install"
85- pnpm install
86-
87- - uses : DavidAnson/markdownlint-cli2-action@v22
88- if : steps.changed-files.outputs.count > 0
89- with :
90- config : ' .markdownlint.json'
1+ name : Markdown
2+
3+ on : pull_request
4+
5+ # Allow this job to clone the repo
6+ permissions :
7+ contents : read
8+ id-token : write
9+
10+ concurrency :
11+ group : ${{ github.workflow }}-${{ github.ref }}
12+ cancel-in-progress : true
13+
14+ jobs :
15+ lint :
16+ runs-on : ubuntu-latest
17+ strategy :
18+ fail-fast : true
19+
20+ steps :
21+ - name : Checkout
22+ uses : actions/checkout@v7
23+ with :
24+ fetch-depth : 0 # Fetch all history for comparison
25+
26+ - name : Load versions
27+ run : cat .github/versions.env >> "$GITHUB_ENV"
28+
29+ - name : Get changed markdown files
30+ id : changed-files
31+ run : |
32+ # Fetch the base branch
33+ git fetch origin ${{ github.base_ref }}
34+
35+ # Get changed .md and .mdx files
36+ CHANGED_FILES=$(git diff --name-only --diff-filter=ACMRT origin/${{ github.base_ref }}...HEAD | grep -E '\.(md|mdx)$' || true)
37+
38+ # Store the files
39+ echo "files<<EOF" >> $GITHUB_OUTPUT
40+ echo "$CHANGED_FILES" >> $GITHUB_OUTPUT
41+ echo "EOF" >> $GITHUB_OUTPUT
42+
43+ # Count files
44+ if [ -z "$CHANGED_FILES" ]; then
45+ echo "count=0" >> $GITHUB_OUTPUT
46+ else
47+ echo "count=$(echo "$CHANGED_FILES" | wc -l)" >> $GITHUB_OUTPUT
48+ fi
49+
50+ - name : Install pnpm
51+ if : steps.changed-files.outputs.count > 0
52+ uses : pnpm/action-setup@v6
53+ with :
54+ version : ${{ env.PNPM_VERSION }}
55+ run_install : false
56+
57+ - name : Setup Node
58+ if : steps.changed-files.outputs.count > 0
59+ uses : actions/setup-node@v6
60+ with :
61+ node-version : ${{ env.NODE_VERSION }}
62+ cache : ' pnpm'
63+ cache-dependency-path : ' pnpm-lock.yaml'
64+
65+ - name : Get pnpm store directory
66+ if : steps.changed-files.outputs.count > 0
67+ shell : bash
68+ run : |
69+ echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
70+
71+ - uses : actions/cache@v6
72+ if : steps.changed-files.outputs.count > 0
73+ name : Setup pnpm cache
74+ with :
75+ path : ${{ env.STORE_PATH }}
76+ key : ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
77+ restore-keys : |
78+ ${{ runner.os }}-pnpm-store-
79+
80+ - name : PNPM install
81+ if : steps.changed-files.outputs.count > 0
82+ run : |
83+ echo; echo "cd to workspace"
84+ cd $GITHUB_WORKSPACE
85+ echo; echo "listing"
86+ ls
87+ echo; echo "PNPM install"
88+ pnpm install
89+
90+ - uses : DavidAnson/markdownlint-cli2-action@v23
91+ if : steps.changed-files.outputs.count > 0
92+ with :
93+ config : ' .markdownlint.json'
9194 globs : ${{ steps.changed-files.outputs.files }}
0 commit comments