diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index dd3354f..23ad4d1 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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 diff --git a/README.md b/README.md index 988808a..5eb9b05 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/action.yml b/action.yml index 668b685..02a6d40 100644 --- a/action.yml +++ b/action.yml @@ -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 diff --git a/entrypoint.sh b/entrypoint.sh index 8df3306..5311003 100755 --- a/entrypoint.sh +++ b/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:-}