-
-
Notifications
You must be signed in to change notification settings - Fork 25
/
script.sh
executable file
·69 lines (54 loc) · 1.96 KB
/
script.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#!/bin/sh
TEMP_PATH="$(mktemp -d)"
PATH="${TEMP_PATH}:$PATH"
export REVIEWDOG_GITHUB_API_TOKEN="${INPUT_GITHUB_TOKEN}"
STYLELINT_FORMATTER="${GITHUB_ACTION_PATH}/stylelint-formatter-rdjson/index.js"
__run_stylelint() {
cmd="stylelint ${INPUT_STYLELINT_INPUT} --custom-formatter ${STYLELINT_FORMATTER}"
if [ -n "${INPUT_STYLELINT_CONFIG}" ]; then
cmd="${cmd} --config='${INPUT_STYLELINT_CONFIG}'"
fi
if [ -n "${INPUT_STYLELINT_IGNORE}" ]; then
cmd="${cmd} --ignore-pattern='${INPUT_STYLELINT_IGNORE}'"
fi
npx --no-install -c "${cmd}" 2>&1
}
__run_reviewdog() {
reviewdog -f=rdjson \
-name="${INPUT_NAME}" \
-reporter="${INPUT_REPORTER}" \
-level="${INPUT_LEVEL}" \
-filter-mode="${INPUT_FILTER_MODE}" \
-fail-on-error="${INPUT_FAIL_ON_ERROR}"
}
cd "${GITHUB_WORKSPACE}/${INPUT_WORKDIR}" || exit 1
echo '::group:: Installing reviewdog 🐶 ... https://github.com/reviewdog/reviewdog'
curl -sfL https://raw.githubusercontent.com/reviewdog/reviewdog/master/install.sh | sh -s -- -b "${TEMP_PATH}" "${REVIEWDOG_VERSION}" 2>&1
echo '::endgroup::'
npx --no-install -c 'stylelint --version'
if [ $? -ne 0 ]; then
echo '::group:: Running `npm install` to install stylelint ...'
npm install
echo '::endgroup::'
fi
if [ -n "${INPUT_PACKAGES}" ]; then
echo '::group:: Running `npm install` to install input packages ...'
npm install ${INPUT_PACKAGES}
echo '::endgroup::'
fi
echo "stylelint version: $(npx --no-install -c 'stylelint --version')"
echo '::group:: Running stylelint with reviewdog 🐶 ...'
stylelint_results=$(__run_stylelint)
# stylelint exit codes are documented here:
# https://stylelint.io/user-guide/cli/#exit-codes
stylelint_rc=$?
if [ $stylelint_rc -ne 0 ] && [ $stylelint_rc -ne 2 ]; then
echo 'stylelint failed'
echo "${stylelint_results}"
echo '::endgroup::'
exit $stylelint_rc
fi
echo "${stylelint_results}" | __run_reviewdog
reviewdog_rc=$?
echo '::endgroup::'
exit $reviewdog_rc