Skip to content

Commit ee0bcd6

Browse files
committed
Add disable, dot, and enable inputs
1 parent ec9432f commit ee0bcd6

File tree

3 files changed

+45
-11
lines changed

3 files changed

+45
-11
lines changed

.pre-commit-config.yaml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,4 @@ repos:
2929
- --config-file=.yamllint
3030
- --strict
3131

32-
- repo: https://github.com/rhysd/actionlint
33-
rev: v1.6.13
34-
hooks:
35-
- id: actionlint
36-
3732
minimum_pre_commit_version: !!str 2.19

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: 37 additions & 4 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
@@ -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
@@ -65,6 +95,9 @@ runs:
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

Comments
 (0)