@@ -16,6 +16,15 @@ inputs:
1616 description : configuration file (JSON or YAML)
1717 required : false
1818 deprecationMessage : Please use 'config' instead.
19+ disable :
20+ description : enable certain rules, for example 'MD013 MD041'
21+ required : false
22+ dot :
23+ description : if 'true', include files/folders with a dot (for example '.github')
24+ required : false
25+ enable :
26+ description : enable certain rules, for example 'MD013 MD041'
27+ required : false
1928 files :
2029 description : files, directories, or globs
2130 required : true
@@ -43,17 +52,38 @@ runs:
4352 - run : |
4453 echo '::group::Installing markdownlint-cli'
4554 version="$(npm view --json markdownlint-cli@${INPUT_CLI_VERSION:?} | jq -r .version)"
55+ IFS='.'; set -- "${version}"; unset IFS
56+ major_version="$1"
57+ minor_version="$2"
4658 prefix="${RUNNER_TOOL_CACHE:-${RUNNER_TEMP:?}}/markdownlint-cli/${version}"
4759 mkdir -p "${prefix}"
4860 # FIXME: --global and --production are deprecated
4961 NPM_CONFIG_PREFIX="${prefix}" npm install --global --production "markdownlint-cli@${version}"
5062 echo '::endgroup::'
5163
5264 markdownlint="${prefix}/bin/markdownlint"
53- markdownlint="${markdownlint}${INPUT_CONFIG_FILE:+ -c ${INPUT_CONFIG_FILE:?}}"
54- markdownlint="${markdownlint}${INPUT_IGNORE:+ -i ${INPUT_IGNORE:?}}"
55- markdownlint="${markdownlint}${INPUT_IGNORE_PATH:+ -p ${INPUT_IGNORE_PATH:?}}"
56- markdownlint="${markdownlint}${INPUT_RULES:+ -r ${INPUT_RULES:?}}"
65+ markdownlint+="${INPUT_CONFIG_FILE:+ -c ${INPUT_CONFIG_FILE:?}}"
66+ if [[ ${major_version} -gt 0 ]] || [[ ${minor_version} -ge 30 ]]; then
67+ markdownlint+="${INPUT_DISABLE:+ --disable ${INPUT_DISABLE:?}}"
68+ fi
69+ if [[ ${major_version} -gt 0 ]] || [[ ${minor_version} -ge 27 ]]; then
70+ if [[ "$(tr '[:upper:]' '[:lower:]' <<<"${INPUT_DOT}")" == true ]]; then
71+ markdownlint+=' --dot'
72+ fi
73+ fi
74+ if [[ ${major_version} -gt 0 ]] || [[ ${minor_version} -ge 30 ]]; then
75+ markdownlint+="${INPUT_ENABLE:+ --enable ${INPUT_ENABLE:?}}"
76+ fi
77+ if [[ ${major_version} -gt 0 ]] || [[ ${minor_version} -ge 7 ]]; then
78+ markdownlint+="${INPUT_IGNORE:+ -i ${INPUT_IGNORE:?}}"
79+ fi
80+ if [[ ${major_version} -gt 0 ]] || [[ ${minor_version} -ge 22 ]]; then
81+ markdownlint+="${INPUT_IGNORE_PATH:+ -p ${INPUT_IGNORE_PATH:?}}"
82+ fi
83+ if [[ ${major_version} -gt 0 ]] || [[ ${minor_version} -ge 11 ]]; then
84+ markdownlint+="${INPUT_RULES:+ -r ${INPUT_RULES:?}}"
85+ fi
86+ printf 'Constructed %s\n' "${markdownlint}"
5787
5888 echo "::add-matcher::${GITHUB_ACTION_PATH:?}/markdownlint-problem-matcher.json"
5989 # shellcheck disable=SC2086
6595 env:
6696 INPUT_CLI_VERSION: ${{ inputs.cli-version }}
6797 INPUT_CONFIG_FILE: ${{ inputs.config || inputs.config_file }}
98+ INPUT_DISABLE: ${{ inputs.disable }}
99+ INPUT_DOT: ${{ inputs.dot }}
100+ INPUT_ENABLE: ${{ inputs.enable }}
68101 INPUT_FILES: ${{ inputs.files }}
69102 INPUT_IGNORE: ${{ inputs.ignore || inputs.ignore_files }}
70103 INPUT_IGNORE_PATH: ${{ inputs.ignore-path || inputs.ignore_path }}
0 commit comments