From aa7825e318ba52f9ac4e829c110d6594a53af59a Mon Sep 17 00:00:00 2001 From: Josh Soref <2119212+jsoref@users.noreply.github.com> Date: Thu, 9 Nov 2023 17:46:50 -0500 Subject: [PATCH] Add step summary --- run-scalafmt.sh | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/run-scalafmt.sh b/run-scalafmt.sh index 5c25705..48e6a40 100755 --- a/run-scalafmt.sh +++ b/run-scalafmt.sh @@ -1,2 +1,29 @@ #!/bin/sh -scalafmt --non-interactive $args +output=$(mktemp) +warnings=$(mktemp) +scalafmt --non-interactive $args > "$output" 2> "$warnings" +result=$? +cat "$output" +cat "$warnings" >&2 +[ $result -eq 0 ] && exit + +report() { + file="$1" + summary="$2" + + [ -s "$file" ] || return + echo "
$summary" + echo + echo '```' + cat "$file" + echo '```' + echo '
' + echo +} + +( + echo "# scalafmt failed ($result)" + report "$output" "Output" + report "$warnings" "Warnings" +) >> "$GITHUB_STEP_SUMMARY" +exit $result