forked from ScaCap/action-ktlint
-
Notifications
You must be signed in to change notification settings - Fork 1
/
entrypoint.sh
executable file
·47 lines (37 loc) · 1.23 KB
/
entrypoint.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
#!/bin/sh
export RELATIVE=
export ANDROID=
export BASELINE=
if [ "$INPUT_KTLINT_VERSION" = "latest" ]; then
curl -sSL https://api.github.com/repos/pinterest/ktlint/releases/latest --header "authorization: Bearer ${INPUT_GITHUB_TOKEN}" |
grep "browser_download_url.*ktlint\"" |
cut -d : -f 2,3 |
tr -d \" |
wget -qi - &&
chmod a+x ktlint &&
mv ktlint /usr/local/bin/
else
curl -sSLO https://github.com/pinterest/ktlint/releases/download/"${INPUT_KTLINT_VERSION}"/ktlint &&
chmod a+x ktlint &&
mv ktlint /usr/local/bin/
fi
if [ "$INPUT_RELATIVE" = true ]; then
export RELATIVE=--relative
fi
if [ ! -z "$INPUT_BASELINE" ]; then
export BASELINE="--baseline=${INPUT_BASELINE}"
fi
if [ "$INPUT_ANDROID" = true ]; then
export ANDROID=--android
fi
cd "$GITHUB_WORKSPACE"
git config --global --add safe.directory $GITHUB_WORKSPACE
export REVIEWDOG_GITHUB_API_TOKEN="${INPUT_GITHUB_TOKEN}"
echo ktlint version: "$(ktlint --version)"
ktlint --reporter=checkstyle $RELATIVE $ANDROID $BASELINE $INPUT_FILE_GLOB |
reviewdog -f=checkstyle \
-name="${INPUT_NAME}" \
-reporter="${INPUT_REPORTER}" \
-level="${INPUT_LEVEL}" \
-filter-mode="${INPUT_FILTER_MODE}" \
-fail-on-error="${INPUT_FAIL_ON_ERROR}"