-
Notifications
You must be signed in to change notification settings - Fork 12
/
entrypoint.sh
executable file
·72 lines (58 loc) · 1.89 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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#!/bin/bash
set -e
function main() {
if usesBoolean "${HTML5_ACTION_DEBUG}"; then
set -x
INPUT_LOG_LEVEL=DEBUG
python --version
html5validator --version
git --version
fi
# Make sure repo is safe. See #31 for more info. Upstream Issue: https://github.com/actions/checkout/issues/760
git config --global --add safe.directory /github/workspace
if ! uses "${INPUT_ROOT}" && ! uses "${INPUT_CONFIG}"; then
echo "result=no config file or root path given" >> $GITHUB_OUTPUT
echo ::error::"Need either root or config file"
exit 1
fi
echo "Running Validator"
if ! git -C . rev-parse 2>/dev/null && ! usesBoolean "${INPUT_SKIP_GIT_CHECK}"; then
echo "result=There is no git respository detected" >> $GITHUB_OUTPUT
echo ::error::"There is no git respository detected"
exit 1
fi
BuildARGS=''
if uses "${INPUT_FORMAT}"; then
BuildARGS+="--format ${INPUT_FORMAT}"
fi
if uses "${INPUT_BLACKLIST}"; then
BuildARGS+=" --blacklist ${INPUT_BLACKLIST}"
fi
if usesBoolean "${INPUT_CSS}"; then
BuildARGS+=" --also-check-css"
fi
if uses "${INPUT_CONFIG}"; then
html5validator --config "${INPUT_CONFIG}" |& tee log.log
result=${PIPESTATUS[0]}
else
if [ "${INPUT_ROOT}" == "" ]; then
echo "result=There is no root given" >> $GITHUB_OUTPUT
echo ::error::"There is no root given"
exit 1
fi
html5validator --root "${INPUT_ROOT}" --log "${INPUT_LOG_LEVEL}" ${BuildARGS} ${INPUT_EXTRA} |& tee log.log
result=${PIPESTATUS[0]}
fi
if usesBoolean "${INPUT_ACTION_DEBUG}"; then
echo "$result"
fi
echo "result=$result" >> $GITHUB_OUTPUT
exit "$result"
}
function uses() {
[ -n "${1}" ]
}
function usesBoolean() {
[ -n "${1}" ] && [ "${1}" = "true" ]
}
main