Skip to content
You're viewing an older version of this GitHub Action. Do you want to see the latest version instead?

markdownlint-cli2-action

A GitHub Action to run the markdownlint-cli2 tool for linting Markdown/CommonMark files with markdownlint

markdownlint-cli2 has extensive support for configuring options and disabling or customizing markdownlint rules. See the markdownlint-cli2 README for more information. markdownlint includes a wide variety of rules for analyzing and improving Markdown content. See the markdownlint README for more information.

Inputs

command (optional)

Command to run (unset, fix, or config)

If unspecified or "", the markdownlint-cli2 command is run.

If set to fix, the markdownlint-cli2-fix command is run and supported issues will be fixed automatically.

If set to config, the markdownlint-cli2-config command is run and the first element of globs should specify a supported configuration file.

For more detail: documentation for markdownlint-cli2.

globs (optional)

Glob expression(s) of files to lint (newline-delimited by default)

The default *.{md,markdown} lints all Markdown files in the base directory of a project.

For more detail: glob syntax in markdownlint-cli2.

separator (optional)

String to use as a separator for the globs input (defaults to newline)

Allows the globs input to use something other than \n to separate glob expressions.

Outputs

[None]

Examples

To lint Markdown files in the base directory of a project:

- uses: DavidAnson/markdownlint-cli2-action@v8

To lint all Markdown files in a project:

- uses: DavidAnson/markdownlint-cli2-action@v8
  with:
    globs: '**/*.md'

To lint specific Markdown files in a project:

- uses: DavidAnson/markdownlint-cli2-action@v8
  with:
    globs: |
      README.md
      CHANGELOG.md
      docs/*.md

To use a custom separator:

- uses: DavidAnson/markdownlint-cli2-action@v8
  with:
    globs: 'README.md,CHANGELOG.md,docs/*.md'
    separator: ','

To fix supported issues when linting:

- uses: DavidAnson/markdownlint-cli2-action@v8
  with:
    command: fix
    globs: '**/*.md'

To specify a custom configuration file:

- uses: DavidAnson/markdownlint-cli2-action@v8
  with:
    command: config
    globs: |
      config/custom.markdownlint.jsonc
      **/*.md

To prevent linting issues from failing the workflow run:

- uses: DavidAnson/markdownlint-cli2-action@v8
  continue-on-error: true

See example.yml for a simple GitHub workflow that uses markdownlint-cli2-action.

See changed.yml for a GitHub workflow that lints only the Markdown files that changed in the most recent commit (useful for Pull Requests and/or gradually introducing linting rules to a new repository).