From f39ff007253f7a61459ecbd0878d6ab14a8ca84d Mon Sep 17 00:00:00 2001 From: Bonobo Date: Mon, 10 Aug 2026 03:07:22 +0200 Subject: [PATCH] fix(output): close capture record before returning failures A nonzero drone-ssh pipeline previously exited under errexit before writing the closing GITHUB_OUTPUT delimiter. Capture the pipefail status inside an if condition, finish the record, then return that status. Add a separator only when stdout lacks a final newline so successful captured values retain their existing shape. --- entrypoint.sh | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/entrypoint.sh b/entrypoint.sh index 123c26d..5dd90c2 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -72,8 +72,17 @@ fi echo "=======================================" if [[ "${INPUT_CAPTURE_STDOUT}" == 'true' ]]; then echo 'stdout<> "${GITHUB_OUTPUT}" - "${TARGET}" "$@" | tee -a "${GITHUB_OUTPUT}" + if "${TARGET}" "$@" | tee -a "${GITHUB_OUTPUT}"; then + capture_status=0 + else + capture_status=$? + fi + output_last_byte_newline_count="$(tail -c 1 "${GITHUB_OUTPUT}" | wc -l)" + if [[ "${output_last_byte_newline_count}" -eq 0 ]]; then + echo >> "${GITHUB_OUTPUT}" + fi echo 'EOF' >> "${GITHUB_OUTPUT}" + exit "${capture_status}" else "${TARGET}" "$@" fi