2020-02-17 21:02:36 -05:00
|
|
|
#!/bin/bash -l
|
2021-10-07 04:05:58 -04:00
|
|
|
# shellcheck disable=SC2086
|
|
|
|
set -o pipefail
|
2019-10-16 04:43:28 -04:00
|
|
|
|
2019-12-17 06:50:34 -05:00
|
|
|
echo "======================"
|
|
|
|
echo "= Linting YAML files ="
|
|
|
|
echo "======================"
|
|
|
|
|
2021-10-07 04:05:58 -04:00
|
|
|
if [[ -z "$LOGFILE" ]]; then
|
|
|
|
LOGFILE=$(mktemp yamllint-XXXXXX)
|
|
|
|
fi
|
|
|
|
|
2020-02-17 21:02:36 -05:00
|
|
|
if [[ -n "$INPUT_CONFIG_FILE" ]]; then
|
|
|
|
options+=(-c "$INPUT_CONFIG_FILE")
|
2019-10-16 04:43:28 -04:00
|
|
|
fi
|
|
|
|
|
2020-02-17 21:02:36 -05:00
|
|
|
if [[ -n "$INPUT_CONFIG_DATA" ]]; then
|
|
|
|
options+=(-d "$INPUT_CONFIG_DATA")
|
2019-10-16 04:47:45 -04:00
|
|
|
fi
|
|
|
|
|
2020-02-17 21:02:36 -05:00
|
|
|
options+=(-f "$INPUT_FORMAT")
|
|
|
|
|
|
|
|
if [[ "$INPUT_STRICT" == "true" ]]; then
|
|
|
|
options+=(-s)
|
2019-10-16 04:47:45 -04:00
|
|
|
fi
|
|
|
|
|
2021-05-26 02:56:08 -04:00
|
|
|
if [[ "$INPUT_NO_WARNINGS" == "true" ]]; then
|
|
|
|
options+=(--no-warnings)
|
|
|
|
fi
|
|
|
|
|
2020-02-17 21:02:36 -05:00
|
|
|
# Enable globstar so ** globs recursively
|
|
|
|
shopt -s globstar
|
|
|
|
|
2021-10-07 04:05:58 -04:00
|
|
|
yamllint "${options[@]}" ${INPUT_FILE_OR_DIR:-.} | tee -a "$LOGFILE"
|
2021-08-19 12:14:17 -04:00
|
|
|
exitcode=$?
|
|
|
|
|
2021-08-18 09:23:29 -04:00
|
|
|
shopt -u globstar
|
2021-10-07 04:05:58 -04:00
|
|
|
echo "::set-output name=logfile::$(realpath ${LOGFILE})"
|
2021-08-19 12:14:17 -04:00
|
|
|
|
|
|
|
exit $exitcode
|