Update hadolint.sh

This commit is contained in:
apoorva2809 2023-09-01 11:28:27 +05:30 committed by GitHub
parent d292784f8f
commit 8833294059
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -7,10 +7,10 @@ PROBLEM_MATCHER_FILE="/problem-matcher.json"
if [ -f "$PROBLEM_MATCHER_FILE" ]; then if [ -f "$PROBLEM_MATCHER_FILE" ]; then
cp "$PROBLEM_MATCHER_FILE" "$HOME/" cp "$PROBLEM_MATCHER_FILE" "$HOME/"
fi fi
# After the run has finished we remove the problem-matcher.json from
# After the run has finished, we remove the problem-matcher.json from
# the repository so we don't leave the checkout dirty. We also remove # the repository so we don't leave the checkout dirty. We also remove
# the matcher so it won't take effect in later steps. # the matcher so it won't take effect in later steps.
# shellcheck disable=SC2317
cleanup() { cleanup() {
echo "::remove-matcher owner=brpaz/hadolint-action::" echo "::remove-matcher owner=brpaz/hadolint-action::"
} }
@ -34,21 +34,35 @@ if [ "$HADOLINT_RECURSIVE" = "true" ]; then
filename="${!#}" filename="${!#}"
flags="${*:1:$#-1}" flags="${*:1:$#-1}"
# Check if filename and directory name are the same
if [ "$(basename "$filename")" != "$(dirname "$filename")" ]; then
# Run hadolint command and save the results to a variable
RESULTS=$(eval "$COMMAND $flags" -- **/"$filename") RESULTS=$(eval "$COMMAND $flags" -- **/"$filename")
else
flags=$*
RESULTS=$(eval "$COMMAND" "$flags")
fi
FAILED=$?
if [ -n "$HADOLINT_OUTPUT" ]; then # Check if HADOLINT_OUTPUT is specified and save results to file
if [ -n "$HADOLINT_OUTPUT" ]; then
if [ -f "$HADOLINT_OUTPUT" ]; then if [ -f "$HADOLINT_OUTPUT" ]; then
HADOLINT_OUTPUT="$TMP_FOLDER/$HADOLINT_OUTPUT" HADOLINT_OUTPUT="$TMP_FOLDER/$HADOLINT_OUTPUT"
fi fi
echo "$RESULTS" >"$HADOLINT_OUTPUT" echo -n "$RESULTS" >"$HADOLINT_OUTPUT"
fi fi
else
# Skip the check if filename and directory name are the same
RESULTS=""
fi
else
flags=$*
# Run hadolint command and save the results to a variable
RESULTS=$(eval "$COMMAND" "$flags")
RESULTS="${RESULTS//$'\\n'/''}" # Check if HADOLINT_OUTPUT is specified and save results to file
if [ -n "$HADOLINT_OUTPUT" ]; then
if [ -f "$HADOLINT_OUTPUT" ]; then
HADOLINT_OUTPUT="$TMP_FOLDER/$HADOLINT_OUTPUT"
fi
echo -n "$RESULTS" >"$HADOLINT_OUTPUT"
fi
fi
{ {
echo "results<<EOF" echo "results<<EOF"