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:
parent
83b3de1e17
commit
bc289f2eaa
1 changed files with 12 additions and 11 deletions
23
hadolint.sh
23
hadolint.sh
|
@ -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"
|
||||
|
|
Loading…
Reference in a new issue