yamllint/entrypoint.sh

41 lines
791 B
Bash
Raw Permalink Normal View History

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