From df73a7fabb0c33f060797475a9efcc41ea9d8f45 Mon Sep 17 00:00:00 2001 From: Jeremy Fiel Date: Tue, 17 Dec 2024 14:19:07 -0500 Subject: [PATCH] feat(actions): add gh action for markdown linting of the spec file --- .github/workflows/validate-markdown.yaml | 6 +++--- package.json | 2 +- scripts/format-markdown.sh | 5 +++++ 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/.github/workflows/validate-markdown.yaml b/.github/workflows/validate-markdown.yaml index ab0828d..5b87c99 100644 --- a/.github/workflows/validate-markdown.yaml +++ b/.github/workflows/validate-markdown.yaml @@ -3,7 +3,7 @@ name: validate-markdown # Author: @ralfhandl based on work of @MikeRalphson # -# This workflow validates markdown files in the `versions` and `schemas` directories matching *.md +# This workflow validates markdown files in the `versions` directory matching *.md # # run this on push to any branch and creation of pull-requests @@ -25,6 +25,6 @@ jobs: with: node-version: '20.x' - name: Validate markdown - run: npx --yes mdv ./{versions,schemas/**}/*.md + run: npx --yes mdv ./versions/[1-2].*.md - name: Lint markdown - run: npx --yes markdownlint-cli --config .markdownlint.yaml ./{versions,schemas/**}/*.md + run: npx --yes markdownlint-cli --config .markdownlint.yaml versions/1.0.[^0].md versions/1.[1-9].*.md versions/2.*.md diff --git a/package.json b/package.json index d0fbf91..ca925c4 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,7 @@ "scripts": { "build": "bash ./scripts/md2html/build.sh", "test": "echo \"Error: no test specified\" && exit 1", - "format-markdown": "bash ./scripts/format-markdown.sh ./{versions,schemas/**}/*.md" + "format-markdown": "bash ./scripts/format-markdown.sh versions/1.0.[^0].md versions/1.[1-9].*.md versions/2.*.md" }, "repository": { "type": "git", diff --git a/scripts/format-markdown.sh b/scripts/format-markdown.sh index c04b971..c0f5246 100644 --- a/scripts/format-markdown.sh +++ b/scripts/format-markdown.sh @@ -3,6 +3,11 @@ SRCDIR="$(dirname "${BASH_SOURCE[0]}")" # check on Windows for filename in $*; do + # check if the $filename exists and if it's writeable + if [ ! -w $filename ]; then + echo "No matching file found: $filename" + continue; + fi # mostly to format code blocks with examples, unfortunately messes up bullet lists and tables npx prettier --write --single-quote $filename