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@v6
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@v3
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'
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@v6
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@v5
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'
9494 globs : ${{ steps.changed-files.outputs.files }}
0 commit comments