Skip to content

Commit

Permalink
Rename some inputs, add disable, dot, and enable
Browse files Browse the repository at this point in the history
  • Loading branch information
nosborn committed Jun 8, 2022
1 parent b4d5756 commit e41974b
Show file tree
Hide file tree
Showing 4 changed files with 73 additions and 28 deletions.
11 changes: 6 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ jobs:
id: expect-failure
uses: ./
with:
config_file: .markdownlintrc
config: .markdownlintrc
dot: true
files: .
rules: examples/rules/custom.js
continue-on-error: true
Expand All @@ -42,14 +43,14 @@ jobs:
- name: Test ignore_files
uses: ./
with:
config_file: .markdownlintrc
config: .markdownlintrc
files: .
ignore_files: examples/ignore/*
ignore: examples/ignore/*
rules: examples/rules/custom.js
- name: Test ignore_path
uses: ./
with:
config_file: .markdownlintrc
config: .markdownlintrc
files: .
ignore_path: examples/.markdownlintignore
ignore-path: examples/.markdownlintignore
rules: examples/rules/custom.js
42 changes: 27 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,25 +10,37 @@ 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@v4.0.0
with:
files: .
config-file: .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 patterns
- `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`
- `ignore_path` (optional) - path to file with ignore patterns - superseded by `ignore-path`

## License

Expand Down
22 changes: 22 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,40 @@ 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
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-path:
description: path to file with ignore pattern(s)
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
deprecationMessage: Please use 'ignore-path' instead.
rules:
description: custom rule files
required: false
Expand Down
26 changes: 18 additions & 8 deletions entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,20 +1,30 @@
#!/bin/sh

env | sort -u

set -eu

MARKDOWNLINT=markdownlint
MARKDOWNLINT="${MARKDOWNLINT}${INPUT_CONFIG_FILE:+ -c ${INPUT_CONFIG_FILE}}"
MARKDOWNLINT="${MARKDOWNLINT}${INPUT_IGNORE_FILES:+ -i ${INPUT_IGNORE_FILES}}"
MARKDOWNLINT="${MARKDOWNLINT}${INPUT_IGNORE_PATH:+ -p ${INPUT_IGNORE_PATH}}"
MARKDOWNLINT="${MARKDOWNLINT}${INPUT_RULES:+ -r ${INPUT_RULES}}"
MARKDOWNLINT="${MARKDOWNLINT}${INPUT_CONFIG:+ -c ${INPUT_CONFIG:?}}"
MARKDOWNLINT="${MARKDOWNLINT}${INPUT_DISABLE:+ --disable ${INPUT_DISABLE:?}}"
# shellcheck disable=SC2312
if [ "$(echo "${INPUT_DOT:-false}" | tr '[:upper:]' '[:lower:]')" = true ]; then
MARKDOWNLINT="${MARKDOWNLINT} --dot"
fi
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:?}"

printf 'Constructed %s\n' "${MARKDOWNLINT}" >&2
# shellcheck disable=SC2086
${MARKDOWNLINT} ${INPUT_FILES}
readonly RC=$?
${MARKDOWNLINT} ${INPUT_FILES:?} || readonly rc=$?

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

exit ${RC}
exit "${rc:-0}"

0 comments on commit e41974b

Please sign in to comment.