Skip to content

Commit

Permalink
feat: use 'set-output name=results'
Browse files Browse the repository at this point in the history
This will introduce a parameter with name results that holds the
hadolint output. Other steps in a workflow can make use of this.

Also fix an error with the piping to tee that was broken.
  • Loading branch information
harmw committed Mar 31, 2022
1 parent 83b3de1 commit bc289f2
Showing 1 changed file with 12 additions and 11 deletions.
23 changes: 12 additions & 11 deletions hadolint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,25 +23,26 @@ if [ -z "$HADOLINT_TRUSTED_REGISTRIES" ]; then
unset HADOLINT_TRUSTED_REGISTRIES;
fi

OUTPUT=
if [ -n "$HADOLINT_OUTPUT" ]; then
if [ -f "$HADOLINT_OUTPUT" ]; then
HADOLINT_OUTPUT="$TMP_FOLDER/$HADOLINT_OUTPUT"
fi
OUTPUT=" | tee $HADOLINT_OUTPUT"
fi

FAILED=0
if [ "$HADOLINT_RECURSIVE" = "true" ]; then
shopt -s globstar

filename="${!#}"
flags="${@:1:$#-1}"

hadolint $HADOLINT_CONFIG $flags **/$filename $OUTPUT || FAILED=1
RESULTS=$(hadolint $HADOLINT_CONFIG $flags **/$filename)
else
# shellcheck disable=SC2086
hadolint $HADOLINT_CONFIG "$@" $OUTPUT || FAILED=1
RESULTS=$(hadolint $HADOLINT_CONFIG "$@")
fi
FAILED=$?

echo "::set-output name=results::$RESULTS"

if [ -n "$HADOLINT_OUTPUT" ]; then
if [ -f "$HADOLINT_OUTPUT" ]; then
HADOLINT_OUTPUT="$TMP_FOLDER/$HADOLINT_OUTPUT"
fi
echo "$RESULTS" > $HADOLINT_OUTPUT
fi

[ -z "$HADOLINT_OUTPUT" ] || echo "Hadolint output saved to: $HADOLINT_OUTPUT"
Expand Down

0 comments on commit bc289f2

Please sign in to comment.