Skip to content

Commit 9771ead

Browse files
committed
Add disable, dot, and enable inputs
1 parent f7ffbf8 commit 9771ead

3 files changed

Lines changed: 49 additions & 12 deletions

File tree

.github/workflows/ci.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ jobs:
3232
id: expect-failure
3333
uses: ./
3434
with:
35-
config_file: .markdownlintrc
35+
config: .markdownlintrc
3636
files: .
3737
rules: examples/rules/custom.js
3838
continue-on-error: true
@@ -42,14 +42,14 @@ jobs:
4242
- name: Test ignore_files
4343
uses: ./
4444
with:
45-
config_file: .markdownlintrc
45+
config: .markdownlintrc
4646
files: .
47-
ignore_files: examples/ignore/*
47+
ignore: examples/ignore/*
4848
rules: examples/rules/custom.js
4949
- name: Test ignore_path
5050
uses: ./
5151
with:
52-
config_file: .markdownlintrc
52+
config: .markdownlintrc
5353
files: .
54-
ignore_path: examples/.markdownlintignore
54+
ignore-path: examples/.markdownlintignore
5555
rules: examples/rules/custom.js

README.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,24 @@ Basic usage with all options enabled:
1313
- name: markdownlint-cli
1414
uses: nosborn/github-action-markdown-cli@v4.0.0
1515
with:
16-
cli-version: latest
17-
config-file: .markdownlint.yaml
1816
files: .
17+
config-file: .markdownlint.yaml
18+
disable: MD013 MD041
19+
dot: true
20+
enable: MD013 MD041
1921
ignore-files: examples/ignore/*
2022
ignore-path: examples/.markdownlintignore
2123
rules: examples/rules/custom.js
24+
cli-version: latest
2225
```
2326
2427
## Inputs
2528
2629
- `files` - what to process (files, directories, globs)
2730
- `config` (optional) - configuration file (JSON or YAML)
31+
- `disable` (optional) - disable certain rules, for example `MD013 MD041`
32+
- `dot` (optional) - if `true`, include files/folders with a dot (for example `.github`)
33+
- `enable` (optional) - enable certain rules, for example `MD013 MD041`
2834
- `ignore` (optional) - files to ignore/exclude (file, directory, glob)
2935
- `ignore-path` (optional) - path to file with ignore patterns
3036
- `rules` (optional) - custom rule files (file, directory, glob, package)

action.yml

Lines changed: 36 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -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
@@ -25,14 +34,14 @@ inputs:
2534
ignore-path:
2635
description: path to file with ignore pattern(s)
2736
required: false
28-
deprecationMessage: Please use 'ignore-path' instead.
2937
ignore_files:
3038
description: files to ignore/exclude
3139
required: false
3240
deprecationMessage: Please use 'ignore' instead.
3341
ignore_path:
3442
description: path to file with ignore pattern(s)
3543
required: false
44+
deprecationMessage: Please use 'ignore-path' instead.
3645
rules:
3746
description: custom rule files
3847
required: false
@@ -43,17 +52,36 @@ runs:
4352
- run: |
4453
echo '::group::Installing markdownlint-cli'
4554
version="$(npm view --json markdownlint-cli@${INPUT_CLI_VERSION:?} | jq -r .version)"
55+
major_version="$(cut -d . -f 1 <<<"${version}")"
56+
minor_version="$(cut -d . -f 2 <<<"${version}")"
4657
prefix="${RUNNER_TOOL_CACHE:-${RUNNER_TEMP:?}}/markdownlint-cli/${version}"
4758
mkdir -p "${prefix}"
4859
# FIXME: --global and --production are deprecated
4960
NPM_CONFIG_PREFIX="${prefix}" npm install --global --production "markdownlint-cli@${version}"
5061
echo '::endgroup::'
5162
5263
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:?}}"
64+
markdownlint+="${INPUT_CONFIG_FILE:+ -c ${INPUT_CONFIG_FILE:?}}"
65+
if [[ ${major_version} -gt 0 ]] || [[ ${minor_version} -ge 30 ]]; then
66+
markdownlint+="${INPUT_DISABLE:+ --disable ${INPUT_DISABLE:?}}"
67+
fi
68+
if [[ ${major_version} -gt 0 ]] || [[ ${minor_version} -ge 27 ]]; then
69+
if [[ "$(tr '[:upper:]' '[:lower:]' <<<"${INPUT_DOT}")" == true ]]; then
70+
markdownlint+=' --dot'
71+
fi
72+
fi
73+
if [[ ${major_version} -gt 0 ]] || [[ ${minor_version} -ge 30 ]]; then
74+
markdownlint+="${INPUT_ENABLE:+ --enable ${INPUT_ENABLE:?}}"
75+
fi
76+
if [[ ${major_version} -gt 0 ]] || [[ ${minor_version} -ge 7 ]]; then
77+
markdownlint+="${INPUT_IGNORE:+ -i ${INPUT_IGNORE:?}}"
78+
fi
79+
if [[ ${major_version} -gt 0 ]] || [[ ${minor_version} -ge 22 ]]; then
80+
markdownlint+="${INPUT_IGNORE_PATH:+ -p ${INPUT_IGNORE_PATH:?}}"
81+
fi
82+
if [[ ${major_version} -gt 0 ]] || [[ ${minor_version} -ge 11 ]]; then
83+
markdownlint+="${INPUT_RULES:+ -r ${INPUT_RULES:?}}"
84+
fi
5785
5886
echo "::add-matcher::${GITHUB_ACTION_PATH:?}/markdownlint-problem-matcher.json"
5987
# shellcheck disable=SC2086
@@ -65,6 +93,9 @@ runs:
6593
env:
6694
INPUT_CLI_VERSION: ${{ inputs.cli-version }}
6795
INPUT_CONFIG_FILE: ${{ inputs.config || inputs.config_file }}
96+
INPUT_DISABLE: ${{ inputs.disable }}
97+
INPUT_DOT: ${{ inputs.dot }}
98+
INPUT_ENABLE: ${{ inputs.enable }}
6899
INPUT_FILES: ${{ inputs.files }}
69100
INPUT_IGNORE: ${{ inputs.ignore || inputs.ignore_files }}
70101
INPUT_IGNORE_PATH: ${{ inputs.ignore-path || inputs.ignore_path }}

0 commit comments

Comments
 (0)