1
0
Fork 0
mirror of https://github.com/hadolint/hadolint-action.git synced 2024-08-16 10:09:53 +02:00

feat: use 'set-output name=results'

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.
This commit is contained in:
Harm Weites 2022-03-31 09:51:31 +02:00
parent 83b3de1e17
commit bc289f2eaa
No known key found for this signature in database
GPG key ID: 512F961398DC5619

View file

@ -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"