ruzickap / action-my-markdown-linter

Style checking and linting for Markdown files

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

GitHub Actions: My Markdown Linter ✔

GitHub Marketplace license release GitHub release date GitHub Actions status Docker Hub Build Status

This is a GitHub Action to lint Markdown files. It's using the markdownlint-cli and fd.

See the basic GitHub Action example:

name: markdown_lint
on:
  push:

jobs:
  markdown_lint:
    name: Check Markdown files
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2

      - name: Markdown Lint
        uses: ruzickap/action-my-markdown-linter@v1

Parameters

Variables used by action-my-markdown-linter GitHub Action:

Variable Default Description
config_file .markdownlint.yaml / .markdownlint.yml (if exists) Config file used by markdownlint-cli
debug (not defined) Enable debug mode for the entrypoint.sh script (set -x)
exclude (not defined) Exclude files or directories - see the --exclude parameter of fd command
fd_cmd_params . -0 --extension md --type f --hidden --no-ignore Set your own parameters for fd command. exclude and search_paths parameters are ignored if this is set.
search_paths (not defined) By default all *.md are checked in whole repository, but you can specify directories

Non of the parameters above are "mandatory".

Full example

GitHub Action example:

name: markdown_lint

on:
  push:
    branches:
      - main

jobs:
  markdown_lint:
  name: Check Markdown files
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2

      - name: Markdown Lint
        uses: ruzickap/action-my-markdown-linter@v1
        with:
          config_file: my_markdownlint.yml
          debug: true
          exclude: |
            my_exclude_dir/md_files/
            my_exclude_dir_2/markdown_files/
            CHANGELOG.md
          search_paths: |
            check_dir_1/md_files/
            check_dir_2/markdown_files/

      - name: Markdown Lint - check only 'docs' directory and exclude CHANGELOG.md
        uses: ruzickap/action-my-markdown-linter@v1
        with:
          search_paths: |
            docs/
          exclude: |
            CHANGELOG.md

      - name: Markdown Lint - simple example
        uses: ruzickap/action-my-markdown-linter@v1

      - name: Markdown Lint using pre-built container
        uses: docker://peru/my-markdown-linter@v1

Running locally

It's possible to use the Markdown linter task locally using docker:

docker run --rm -t -v "${PWD}/tests/test2:/mnt" peru/my-markdown-linter

Output:

*** Start checking...
*** Running: fd . -0 --extension md --type f --hidden --no-ignore
*** Running: markdownlint  normal.md
*** Checks completed...

Or you can also use parameters:

export INPUT_EXCLUDE="CHANGELOG.md test1/excluded_file.md bad.md excluded_dir/"
export INPUT_SEARCH_PATHS="tests/"
docker run --rm -t -e INPUT_EXCLUDE -e INPUT_SEARCH_PATHS -v "${PWD}:/mnt" peru/my-markdown-linter

Output:

*** Start checking...
*** Running: fd . -0 --extension md --type f --hidden --no-ignore --exclude CHANGELOG.md --exclude test1/excluded_file.md --exclude bad.md --exclude excluded_dir/ tests/
*** Running: markdownlint  tests/test2/normal.md
*** Checks completed...

Demo:

My Markdown Linter

Examples

Real examples of My Markdown Linter usage:

About

Style checking and linting for Markdown files

License:Apache License 2.0


Languages

Language:Shell 67.0%Language:Dockerfile 33.0%