-
Notifications
You must be signed in to change notification settings - Fork 4
/
entrypoint.sh
41 lines (36 loc) · 1.08 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
#!/usr/bin/env bash
# Return code
RET_CODE=0
WORK_DIR=/github/workspace
# Split dir_filter into array
IFS=',' read -r -a ARRAY <<< "${INPUT_DIR_FILTER}"
# Go through all dir prefixes
for PREFIX in "${ARRAY[@]}"; do
# Go through all matching directories
for DIRECTORY in "${PREFIX}"*; do
[[ -d "${DIRECTORY}" ]] || break
cd "${WORK_DIR}/${DIRECTORY}" || RET_CODE=1
echo -e "\nDirectory: ${DIRECTORY}"
if [[ -f "${WORK_DIR}/${INPUT_TFLINT_CONFIG}" ]]; then
if [[ "${INPUT_RUN_INIT}" == "true" ]]; then
terraform init
fi
tflint --init && tflint -c "${WORK_DIR}/${INPUT_TFLINT_CONFIG}" || RET_CODE=1
else
if [[ "${INPUT_RUN_INIT}" == "true" ]]; then
terraform init
fi
tflint --init && tflint "${INPUT_TFLINT_PARAMS}" || RET_CODE=1
fi
cd "${WORK_DIR}" || RET_CODE=1
done
done
# Finish
if [[ "${RET_CODE}" != "0" ]]; then
echo -e "\n[ERROR] Check log for errors."
exit 1
else
# Pass in other cases
echo -e "\n[INFO] No errors found."
exit 0
fi