-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathentrypoint.sh
executable file
·62 lines (61 loc) · 2.2 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
#!/bin/bash
set -e
if [ ! -z "${DEBUG}" ]; then set -x; fi
if [ -z "${GITHUB_ACTIONS}" ]; then
exec okv ${@}
else
strict_mode='--no-strict'
if [ "${INPUT_STRICT}" = "true" ]; then strict_mode=''; fi
INPUT_CPU_NUM="$(env | sed -n 's/^INPUT_CPU-NUM=\(.*\)/\1/p')"
INPUT_FILE_RESTRICTIONS="$(env | sed -n 's/^INPUT_FILE-RESTRICTIONS=\(.*\)/\1/p')"
schema_flag="--ok=${INPUT_OK}"
if [ ! -z "${INPUT_SCHEMA}" ]; then
schema_flag="--schema=${INPUT_SCHEMA}"
fi
output=""
result="0"
set +e
if [ -z "${INPUT_FILE_RESTRICTIONS}" ]; then
output=$(okv ${schema_flag} --cpu-num=${INPUT_CPU_NUM} --parser=${INPUT_PARSER} ${strict_mode} -path=${INPUT_PATH})
result=$?
echo "${output}"
else
# INPUT_FILE_RESTRICTIONS is expected to be a space-separated array
# of files
file_arr=($INPUT_FILE_RESTRICTIONS)
for file in ${file_arr[@]}; do
# If an input path is also provided, it is expected to serve as an
# enforced prefix for each of the file restrictions. In the case
# of the pull request, this means that added and modified files
# must exist within a particular directory or match a file
if [[ ! -z "${INPUT_PATH}" ]] && [[ "${file}" != ${INPUT_PATH}*.y*ml ]]; then
continue
fi
if [ ! -f "${file}" ]; then
continue
fi
tmp_output=$(okv ${schema_flag} --cpu-num=${INPUT_CPU_NUM} --parser=${INPUT_PARSER} ${strict_mode} -path=${file})
tmp_result=$?
# Loop over all files before throwing non-zero exit below
if [ "${tmp_result}" == "0" ]; then
continue
fi
if [ "${result}" == "0" ]; then
result="$tmp_result"
fi
if [ -z "${output}" ]; then
output="${tmp_output}"
echo "${output}"
else
echo "----
${tmp_output}"
output="${output}
----
${tmp_output}"
fi
done
fi
set -e
echo "::set-output name=results::$(echo $output)"
if [ "${result}" != "0" ]; then exit 1; fi
fi