-
Notifications
You must be signed in to change notification settings - Fork 2
/
entrypoint.sh
executable file
·76 lines (64 loc) · 1.4 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
73
74
75
76
#!/usr/bin/env bash
# Return code
RET_CODE=0
# Print input variables
echo "Inputs:"
echo " list: ${INPUT_LIST}"
echo " write: ${INPUT_WRITE}"
echo " ignore: ${INPUT_IGNORE}"
echo " diff: ${INPUT_DIFF}"
echo " check: ${INPUT_CHECK}"
echo " recursive: ${INPUT_RECURSIVE}"
echo " dir: ${INPUT_DIR}"
# Remap input variables as parameters for format-hcl
LIST="-list=${INPUT_LIST}"
WRITE="-write=${INPUT_WRITE}"
if [[ -n "${INPUT_IGNORE}" ]]; then
IGNORE="-ignore=${INPUT_IGNORE}"
else
IGNORE=""
fi
if [[ "${INPUT_DIFF}" == "true" ]]; then
DIFF="-diff"
else
DIFF=""
fi
if [[ "${INPUT_CHECK}" == "true" ]]; then
CHECK="-check"
else
CHECK=""
fi
if [[ "${INPUT_RECURSIVE}" == "true" ]]; then
RECURSIVE="-recursive"
else
RECURSIVE=""
fi
if [[ -n "${INPUT_DIR}" ]]; then
DIR="${INPUT_DIR}"
else
DIR=""
fi
# Run main action
touch /tmp/time_compare
/usr/bin/format-hcl ${LIST} ${WRITE} ${IGNORE} ${DIFF} ${CHECK} ${RECURSIVE} ${DIR}
RET_CODE=$?
# List of changed files
FILES_CHANGED=$(find . -newer /tmp/time_compare -type f)
# Info about changed files
if [[ -n ${FILES_CHANGED} ]]; then
echo -e "\n[INFO] Updated files:"
for FILE in ${FILES_CHANGED}; do
echo "${FILE}"
done
else
echo -e "\n[INFO] No files updated."
fi
# 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