Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dockerfile is a directory issue Fix #82

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 25 additions & 11 deletions hadolint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ PROBLEM_MATCHER_FILE="/problem-matcher.json"
if [ -f "$PROBLEM_MATCHER_FILE" ]; then
cp "$PROBLEM_MATCHER_FILE" "$HOME/"
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 matcher so it won't take effect in later steps.
# shellcheck disable=SC2317
cleanup() {
echo "::remove-matcher owner=brpaz/hadolint-action::"
}
Expand All @@ -34,22 +34,36 @@ if [ "$HADOLINT_RECURSIVE" = "true" ]; then
filename="${!#}"
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
flags=$*
# Run hadolint command and save the results to a variable
RESULTS=$(eval "$COMMAND" "$flags")
fi
FAILED=$?

if [ -n "$HADOLINT_OUTPUT" ]; then
if [ -f "$HADOLINT_OUTPUT" ]; then
HADOLINT_OUTPUT="$TMP_FOLDER/$HADOLINT_OUTPUT"
# 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
echo "$RESULTS" >"$HADOLINT_OUTPUT"
fi

RESULTS="${RESULTS//$'\\n'/''}"

{
echo "results<<EOF"
echo "$RESULTS"
Expand Down