mirror of
https://github.com/hadolint/hadolint-action.git
synced 2025-01-31 11:51:08 +01:00
Update hadolint.sh
This commit is contained in:
parent
d292784f8f
commit
8833294059
1 changed files with 25 additions and 11 deletions
36
hadolint.sh
36
hadolint.sh
|
@ -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,22 +34,36 @@ if [ "$HADOLINT_RECURSIVE" = "true" ]; then
|
||||||
filename="${!#}"
|
filename="${!#}"
|
||||||
flags="${*:1:$#-1}"
|
flags="${*:1:$#-1}"
|
||||||
|
|
||||||
RESULTS=$(eval "$COMMAND $flags" -- **/"$filename")
|
# 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")
|
||||||
|
|
||||||
|
# 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
|
||||||
|
else
|
||||||
|
# Skip the check if filename and directory name are the same
|
||||||
|
RESULTS=""
|
||||||
|
fi
|
||||||
else
|
else
|
||||||
flags=$*
|
flags=$*
|
||||||
|
# Run hadolint command and save the results to a variable
|
||||||
RESULTS=$(eval "$COMMAND" "$flags")
|
RESULTS=$(eval "$COMMAND" "$flags")
|
||||||
fi
|
|
||||||
FAILED=$?
|
|
||||||
|
|
||||||
if [ -n "$HADOLINT_OUTPUT" ]; then
|
# Check if HADOLINT_OUTPUT is specified and save results to file
|
||||||
if [ -f "$HADOLINT_OUTPUT" ]; then
|
if [ -n "$HADOLINT_OUTPUT" ]; then
|
||||||
HADOLINT_OUTPUT="$TMP_FOLDER/$HADOLINT_OUTPUT"
|
if [ -f "$HADOLINT_OUTPUT" ]; then
|
||||||
|
HADOLINT_OUTPUT="$TMP_FOLDER/$HADOLINT_OUTPUT"
|
||||||
|
fi
|
||||||
|
echo -n "$RESULTS" >"$HADOLINT_OUTPUT"
|
||||||
fi
|
fi
|
||||||
echo "$RESULTS" >"$HADOLINT_OUTPUT"
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
RESULTS="${RESULTS//$'\\n'/''}"
|
|
||||||
|
|
||||||
{
|
{
|
||||||
echo "results<<EOF"
|
echo "results<<EOF"
|
||||||
echo "$RESULTS"
|
echo "$RESULTS"
|
||||||
|
|
Loading…
Add table
Reference in a new issue