Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v4.0.0 #39

Draft
wants to merge 5 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
15 changes: 11 additions & 4 deletions .github/workflows/ci.yml
Expand Up @@ -32,24 +32,31 @@ jobs:
id: expect-failure
uses: ./
with:
config_file: .markdownlintrc
config: .markdownlintrc
files: .
rules: examples/rules/custom.js
continue-on-error: true
- if: ${{ steps.expect-failure.outcome != 'failure' }}
run: |
exit 1
- name: Test ignore_files
- name: Test ignore
uses: ./
with:
config_file: .markdownlintrc
config: .markdownlintrc
files: .
ignore: examples/ignore/*
rules: examples/rules/custom.js
- name: Test ignore_files deprecation
uses: ./
with:
config: .markdownlintrc
files: .
ignore_files: examples/ignore/*
rules: examples/rules/custom.js
- name: Test ignore_path
uses: ./
with:
config_file: .markdownlintrc
config: .markdownlintrc
files: .
ignore_path: examples/.markdownlintignore
rules: examples/rules/custom.js
41 changes: 26 additions & 15 deletions README.md
Expand Up @@ -10,25 +10,36 @@ A GitHub Action that performs style checking and linting for Markdown/CommonMark
Basic usage with all options enabled:

```yaml

- name: markdownlint-cli
uses: nosborn/github-action-markdown-cli@v3.0.1
with:
files: .
config_file: .markdownlint.yaml
ignore_files: examples/ignore/*
ignore_path: examples/.markdownlintignore
rules: examples/rules/custom.js

- name: markdownlint-cli
uses: nosborn/github-action-markdown-cli@v3.0.1
with:
files: .
config: .markdownlint.yaml
disable: MD013 MD041
dot: true
enable: MD013 MD041
ignore: examples/ignore/*
ignore_path: examples/.markdownlintignore
rules: examples/rules/custom.js
```

## Inputs

* `files` - what to process (files, directories, globs)
* `config_file` (optional) - configuration file (JSON or YAML)
* `ignore_files` (optional) - files to ignore/exclude (file, directory, glob)
* `ignore_path` (optional) - path to file with ignore pattern(s)
* `rules` (optional) - custom rule files (file, directory, glob, package)
- `files` - what to process (files, directories, globs)
- `config` (optional) - configuration file (JSON or YAML)
- `disable` (optional) - disable certain rules, for example `MD013 MD041`
- `dot` (optional) - if `true`, include files/folders with a dot (for example `.github`)
- `enable` (optional) - enable certain rules, for example `MD013 MD041`
- `ignore` (optional) - files to ignore/exclude (file, directory, glob)
- `ignore_path` (optional) - path to file with ignore pattern(s)
- `rules` (optional) - custom rule files (file, directory, glob, package)

### Deprecated inputs

These inputs are still available but will be removed in a future major version.

- `config_file` (optional) - configuration file (JSON or YAML) - superseded by `config`
- `ignore_files` (optional) - files to ignore/exclude (file, directory, glob) - superseded by `ignore`

## License

Expand Down
19 changes: 19 additions & 0 deletions action.yml
Expand Up @@ -4,15 +4,34 @@ author: Nick Osborn
description: Style checker and lint tool for Markdown/CommonMark files.

inputs:
config:
description: configuration file (JSON or YAML)
required: false
config_file:
description: configuration file (JSON or YAML)
required: false
deprecationMessage: Please use 'config' instead.
disable:
description: enable certain rules, for example 'MD013 MD041'
required: false
dot:
description: >
if 'true', include files/folders with a dot (for example '.github')
required: false
default: false
enable:
description: enable certain rules, for example 'MD013 MD041'
required: false
files:
description: files, directories, or globs
required: true
ignore:
description: files to ignore/exclude
required: false
ignore_files:
description: files to ignore/exclude
required: false
deprecationMessage: Please use 'ignore' instead.
ignore_path:
description: path to file with ignore pattern(s)
required: false
Expand Down
28 changes: 20 additions & 8 deletions entrypoint.sh
@@ -1,20 +1,32 @@
#!/bin/sh

set -o errexit
set -o nounset

: "${INPUT_CONFIG:=${INPUT_CONFIG_FILE:-}}"
: "${INPUT_IGNORE:=${INPUT_IGNORE_FILES:-}}"

MARKDOWNLINT=markdownlint
MARKDOWNLINT="${MARKDOWNLINT}${INPUT_CONFIG_FILE:+ -c ${INPUT_CONFIG_FILE}}"
MARKDOWNLINT="${MARKDOWNLINT}${INPUT_IGNORE_FILES:+ -i ${INPUT_IGNORE_FILES}}"
MARKDOWNLINT="${MARKDOWNLINT}${INPUT_CONFIG:+ -c ${INPUT_CONFIG}}"
MARKDOWNLINT="${MARKDOWNLINT}${INPUT_DISABLE:+ --disable ${INPUT_DISABLE:?}}"
# shellcheck disable=SC2312
[ "$(echo "${INPUT_DOT:?}" | tr '[:upper:]' '[:lower:]')" = true ] && {
MARKDOWNLINT="${MARKDOWNLINT} --dot"
}
MARKDOWNLINT="${MARKDOWNLINT}${INPUT_ENABLE:+ --enable ${INPUT_ENABLE:?}}"
MARKDOWNLINT="${MARKDOWNLINT}${INPUT_IGNORE:+ -i ${INPUT_IGNORE}}"
MARKDOWNLINT="${MARKDOWNLINT}${INPUT_IGNORE_PATH:+ -p ${INPUT_IGNORE_PATH}}"
MARKDOWNLINT="${MARKDOWNLINT}${INPUT_RULES:+ -r ${INPUT_RULES}}"

PROBLEM_MATCHER="$(mktemp -p "${GITHUB_WORKSPACE}")"
PROBLEM_MATCHER="$(mktemp -p "${GITHUB_WORKSPACE:?}")"
trap 'rm -f "${PROBLEM_MATCHER}"' EXIT
cp /markdownlint-problem-matcher.json "${PROBLEM_MATCHER:?}" || exit
echo "::add-matcher::${PROBLEM_MATCHER:?}"
cp /markdownlint-problem-matcher.json "${PROBLEM_MATCHER}" || exit
echo "::add-matcher::${PROBLEM_MATCHER}"

# shellcheck disable=SC2086
${MARKDOWNLINT} ${INPUT_FILES}
readonly RC=$?
${MARKDOWNLINT} ${INPUT_FILES:?} || readonly rc=$?

echo '::remove-matcher owner=markdownlint::'

exit ${RC}
# shellcheck disable=SC2248
exit ${rc:-}