Skip to content

Commit 7b698a3

Browse files
committed
Use a problem matcher
1 parent b5f9765 commit 7b698a3

File tree

3 files changed

+39
-37
lines changed

3 files changed

+39
-37
lines changed
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"problemMatcher": [
3+
{
4+
"owner": "markdownlint",
5+
"pattern": [
6+
{
7+
"code": 3,
8+
"file": 1,
9+
"line": 2,
10+
"message": 4,
11+
"regexp": "^(.+):(\\d+)(?:\\d+)? (\\S+) (.+)$"
12+
}
13+
]
14+
}
15+
]
16+
}

.github/workflows/ci.yml

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,30 @@ jobs:
2626
runs-on: ubuntu-latest
2727
steps:
2828
- uses: actions/[email protected]
29-
- uses: ./
29+
- name: Test problem matcher
30+
id: expect-failure
31+
uses: ./
32+
with:
33+
config_file: .markdownlintrc
34+
files: .
35+
rules: examples/rules/custom.js
36+
env:
37+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
38+
continue-on-error: true
39+
- if: ${{ steps.expect-failure.outcome != 'failure' }}
40+
run: |
41+
exit 1
42+
- name: Test ignore_files
43+
uses: ./
3044
with:
3145
config_file: .markdownlintrc
3246
files: .
3347
ignore_files: examples/ignore/*
3448
rules: examples/rules/custom.js
3549
env:
3650
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
37-
- uses: ./
51+
- name: Test ignore_path
52+
uses: ./
3853
with:
3954
config_file: .markdownlintrc
4055
files: .

entrypoint.sh

Lines changed: 6 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -6,41 +6,12 @@ MARKDOWNLINT="${MARKDOWNLINT}${INPUT_IGNORE_FILES:+ -i ${INPUT_IGNORE_FILES}}"
66
MARKDOWNLINT="${MARKDOWNLINT}${INPUT_IGNORE_PATH:+ -p ${INPUT_IGNORE_PATH}}"
77
MARKDOWNLINT="${MARKDOWNLINT}${INPUT_RULES:+ -r ${INPUT_RULES}}"
88

9-
# shellcheck disable=SC2086
10-
OUTPUT=$(${MARKDOWNLINT} ${INPUT_FILES} 2>&1)
11-
SUCCESS=$?
12-
echo "${OUTPUT}"
13-
14-
if [ ${SUCCESS} -eq 0 ]; then
15-
exit 0
16-
fi
17-
18-
if [ "${GITHUB_EVENT_NAME}" = pull_request ]; then
19-
comment=""
20-
FILES=$(echo "${OUTPUT}" | cut -d: -f1 | sort | uniq)
21-
22-
for file in ${FILES}; do
23-
comment="${comment}<details><summary><code>${file}</code></summary>
9+
echo '::add-matcher::.github/markdownlint-problem-matcher.json'
2410

25-
\`\`\`
26-
$(echo "${OUTPUT}" | grep "^${file}:" | sed "s/^[^:]*:[[:space:]]*//")
27-
\`\`\`
28-
29-
</details>"
30-
done
31-
32-
COMMENT_BODY="#### Issues with Markdown/CommonMark files
33-
${comment}
34-
35-
*Workflow: \`${GITHUB_WORKFLOW}\`, Action: \`${GITHUB_ACTION}\`*"
36-
PAYLOAD=$(echo '{}' | jq --arg body "${COMMENT_BODY}" '.body = $body')
37-
COMMENTS_URL=$(jq -r .pull_request.comments_url <"${GITHUB_EVENT_PATH}")
11+
# shellcheck disable=SC2086
12+
${MARKDOWNLINT} ${INPUT_FILES}
13+
readonly RC=$?
3814

39-
curl -sS \
40-
-H "Authorization: token ${GITHUB_TOKEN}" \
41-
-H 'Content-Type: application/json' \
42-
-d "${PAYLOAD}" \
43-
"${COMMENTS_URL}" >/dev/null
44-
fi
15+
echo '::remove-matcher owner=markdownlint::'
4516

46-
exit ${SUCCESS}
17+
exit ${RC}

0 commit comments

Comments
 (0)