Skip to content

Commit

Permalink
feat(actions): add gh action for markdown linting of the spec file
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremyfiel committed Dec 17, 2024
1 parent e1b518b commit df73a7f
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/validate-markdown.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
5 changes: 5 additions & 0 deletions scripts/format-markdown.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit df73a7f

Please sign in to comment.