-
-
Notifications
You must be signed in to change notification settings - Fork 16
/
script.sh
executable file
·49 lines (38 loc) · 1.52 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
#!/bin/sh
# shellcheck disable=SC2086,SC2089,SC2090
cd "${GITHUB_WORKSPACE}" || exit
TEMP_PATH="$(mktemp -d)"
PATH="${TEMP_PATH}:$PATH"
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::'
echo '::group:: Installing hadolint ... https://github.com/hadolint/hadolint'
wget -q https://github.com/hadolint/hadolint/releases/download/$HADOLINT_VERSION/hadolint-Linux-x86_64 -O $TEMP_PATH/hadolint \
&& chmod +x $TEMP_PATH/hadolint
echo '::endgroup::'
export REVIEWDOG_GITHUB_API_TOKEN="${INPUT_GITHUB_TOKEN}"
EXCLUDES=""
for exclude_path in $INPUT_EXCLUDE; do
set -- --exclude="!${exclude_path}"
EXCLUDES="$EXCLUDES $*"
done
IGNORE_LIST=""
for rule in $INPUT_HADOLINT_IGNORE; do
IGNORE_LIST="$IGNORE_LIST --ignore $rule"
done
INPUT_HADOLINT_FLAGS="$INPUT_HADOLINT_FLAGS $IGNORE_LIST"
echo '::group:: Running hadolint with reviewdog 🐶 ...'
git ls-files --exclude='*Dockerfile*' --ignored --cached ${EXCLUDES} \
| xargs hadolint -f json ${INPUT_HADOLINT_FLAGS} \
| jq -f "${GITHUB_ACTION_PATH}/to-rdjson.jq" -c \
| reviewdog -f="rdjson" \
-name="${INPUT_TOOL_NAME}" \
-reporter="${INPUT_REPORTER}" \
-filter-mode="${INPUT_FILTER_MODE}" \
-fail-level="${INPUT_FAIL_LEVEL}" \
-fail-on-error="${INPUT_FAIL_ON_ERROR}" \
-level="${INPUT_LEVEL}" \
${INPUT_REVIEWDOG_FLAGS}
EXIT_CODE=$?
echo '::endgroup::'
exit $EXIT_CODE