From 84a94c413e6c8ebbdfc33af93fee0e9cce16e8eb Mon Sep 17 00:00:00 2001
From: yimysty <yimysty@github.com>
Date: Thu, 19 Oct 2023 17:34:27 -0700
Subject: [PATCH] set the right annotation

---
 entrypoint.sh | 21 ++++++++++++++++++---
 1 file changed, 18 insertions(+), 3 deletions(-)

diff --git a/entrypoint.sh b/entrypoint.sh
index 024fe95..1941b75 100755
--- a/entrypoint.sh
+++ b/entrypoint.sh
@@ -6,8 +6,6 @@
 #
 ####################################################################################################
 
-set -o errexit
-
 SOURCE_DIRECTORY=${GITHUB_WORKSPACE}/$INPUT_SOURCE
 DESTINATION_DIRECTORY=${GITHUB_WORKSPACE}/$INPUT_DESTINATION
 PAGES_GEM_HOME=$BUNDLE_APP_CONFIG
@@ -40,4 +38,21 @@ else
 fi
 
 cd "$PAGES_GEM_HOME"
-$GITHUB_PAGES_BIN build "$VERBOSE" "$FUTURE" --source "$SOURCE_DIRECTORY" --destination "$DESTINATION_DIRECTORY"
+
+# Run the command, capturing the output
+build_output="$($GITHUB_PAGES_BIN build "$VERBOSE" "$FUTURE" --source "$SOURCE_DIRECTORY" --destination "$DESTINATION_DIRECTORY")"
+
+# Capture the exit code
+exit_code=$?
+
+if [ $exit_code -ne 0 ]; then
+  # Remove the newlines from the build_output as annotation not support multiline
+  error=$(echo "$build_output" | tr '\n' ' ' | tr -s ' ')
+  echo "::error::$error"
+else
+  # Display the build_output directly
+  echo "$build_output"
+fi
+
+# Exit with the captured exit code
+exit $exit_code