44 workflow_call :
55 inputs :
66 docs-path :
7- description : ' Path to the docs directory (e.g. "docs/ ")'
7+ description : ' Path to the docs directory (e.g. "docs")'
88 required : false
99 type : string
10- default : ' docs/'
11- markdown-glob :
12- description : ' Glob pattern for markdown files'
13- required : false
14- type : string
15- default : ' docs/**/*.md'
10+ default : ' docs'
1611 enable-toc-check :
1712 description : ' Enable TOC link validation (requires .vitepress/toc_*.json)'
1813 required : false
8681
8782 - name : Validate JSON syntax
8883 run : |
89- for file in .vitepress/toc_*.json; do
84+ shopt -s nullglob
85+ files=(.vitepress/toc_*.json)
86+ if [ ${#files[@]} -eq 0 ]; then
87+ echo "No .vitepress/toc_*.json files found"
88+ exit 1
89+ fi
90+ for file in "${files[@]}"; do
9091 if ! jq empty "$file" 2>/dev/null; then
9192 echo "Invalid JSON: $file"
9293 exit 1
@@ -135,8 +136,13 @@ jobs:
135136 - name : Determine config path
136137 id : config
137138 run : |
138- if [ -n "${{ inputs.markdownlint-config }}" ] && [ -f "${{ inputs.markdownlint-config }}" ]; then
139- echo "path=${{ inputs.markdownlint-config }}" >> $GITHUB_OUTPUT
139+ if [ -n "${{ inputs.markdownlint-config }}" ]; then
140+ if [ -f "${{ inputs.markdownlint-config }}" ]; then
141+ echo "path=${{ inputs.markdownlint-config }}" >> $GITHUB_OUTPUT
142+ else
143+ echo "Error: markdownlint config '${{ inputs.markdownlint-config }}' does not exist." >&2
144+ exit 1
145+ fi
140146 else
141147 echo "path=.docs-tools/.github/.markdownlint-cli2.jsonc" >> $GITHUB_OUTPUT
142148 fi
@@ -145,7 +151,7 @@ jobs:
145151 uses : DavidAnson/markdownlint-cli2-action@v23
146152 with :
147153 config : ${{ steps.config.outputs.path }}
148- globs : ${{ inputs.markdown-glob }}
154+ globs : ' ${{ inputs.docs-path }}/**/*.md '
149155
150156 spell-check :
151157 name : Spell Check
@@ -167,16 +173,21 @@ jobs:
167173 - name : Determine config path
168174 id : config
169175 run : |
170- if [ -n "${{ inputs.cspell-config }}" ] && [ -f "${{ inputs.cspell-config }}" ]; then
171- echo "path=${{ inputs.cspell-config }}" >> $GITHUB_OUTPUT
176+ if [ -n "${{ inputs.cspell-config }}" ]; then
177+ if [ -f "${{ inputs.cspell-config }}" ]; then
178+ echo "path=${{ inputs.cspell-config }}" >> $GITHUB_OUTPUT
179+ else
180+ echo "Error: cspell config '${{ inputs.cspell-config }}' does not exist." >&2
181+ exit 1
182+ fi
172183 else
173184 echo "path=.docs-tools/.github/cspell.json" >> $GITHUB_OUTPUT
174185 fi
175186
176187 - name : Check spelling
177188 uses : streetsidesoftware/cspell-action@v8
178189 with :
179- files : ${{ inputs.markdown-glob }}
190+ files : ' ${{ inputs.docs-path }}/**/*.md '
180191 config : ${{ steps.config.outputs.path }}
181192 incremental_files_only : true
182193
@@ -202,19 +213,25 @@ jobs:
202213 - name : Get changed markdown files
203214 id : changed-files
204215 run : |
216+ DOCS_PATH="${{ inputs.docs-path }}"
205217 if [ "${{ github.event_name }}" == "pull_request" ]; then
206- FILES=$(git diff --name-only --diff-filter=d origin/${{ github.base_ref }}...HEAD | grep '\.md$' || true)
218+ BASE_SHA="${{ github.event.pull_request.base.sha }}"
219+ if [ -z "$BASE_SHA" ]; then
220+ git fetch origin "${{ github.base_ref }}" --depth=1 2>/dev/null || true
221+ BASE_SHA="origin/${{ github.base_ref }}"
222+ fi
223+ FILES=$(git diff --name-only --diff-filter=d "${BASE_SHA}"...HEAD | grep "^${DOCS_PATH}/.*\.md$" || true)
207224 if [ -z "$FILES" ]; then
208- echo "No markdown files changed"
225+ echo "No markdown files changed in ${DOCS_PATH}/ "
209226 echo "files=" >> $GITHUB_OUTPUT
210227 else
211228 echo "files=$(echo $FILES | tr '\n' ' ')" >> $GITHUB_OUTPUT
212229 echo "Checking files:"
213230 echo "$FILES"
214231 fi
215232 else
216- echo "files=${{ inputs.markdown-glob }} " >> $GITHUB_OUTPUT
217- echo "Checking all files: ${{ inputs.markdown-glob }} "
233+ echo "files=${DOCS_PATH}/**/*.md " >> $GITHUB_OUTPUT
234+ echo "Checking all files: ${DOCS_PATH}/**/*.md "
218235 fi
219236
220237 - name : Check internal links
0 commit comments