Skip to content

Commit 6eb2eb3

Browse files
authored
Merge pull request #102 from actions/add-error-anotation
2 parents 1e8be5b + 92113c1 commit 6eb2eb3

File tree

1 file changed

+19
-4
lines changed

1 file changed

+19
-4
lines changed

entrypoint.sh

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@
66
#
77
####################################################################################################
88

9-
set -o errexit
10-
119
SOURCE_DIRECTORY=${GITHUB_WORKSPACE}/$INPUT_SOURCE
1210
DESTINATION_DIRECTORY=${GITHUB_WORKSPACE}/$INPUT_DESTINATION
1311
PAGES_GEM_HOME=$BUNDLE_APP_CONFIG
@@ -39,5 +37,22 @@ else
3937
FUTURE=''
4038
fi
4139

42-
cd "$PAGES_GEM_HOME"
43-
$GITHUB_PAGES_BIN build "$VERBOSE" "$FUTURE" --source "$SOURCE_DIRECTORY" --destination "$DESTINATION_DIRECTORY"
40+
{ cd "$PAGES_GEM_HOME" || { echo "::error::pages gem not found"; exit 1; }; }
41+
42+
# Run the command, capturing the output
43+
build_output="$($GITHUB_PAGES_BIN build "$VERBOSE" "$FUTURE" --source "$SOURCE_DIRECTORY" --destination "$DESTINATION_DIRECTORY")"
44+
45+
# Capture the exit code
46+
exit_code=$?
47+
48+
if [ $exit_code -ne 0 ]; then
49+
# Remove the newlines from the build_output as annotation not support multiline
50+
error=$(echo "$build_output" | tr '\n' ' ' | tr -s ' ')
51+
echo "::error::$error"
52+
else
53+
# Display the build_output directly
54+
echo "$build_output"
55+
fi
56+
57+
# Exit with the captured exit code
58+
exit $exit_code

0 commit comments

Comments
 (0)