refactor: streamline output handling for GITHUB_OUTPUT in workflows (#404)

* refactor: streamline output handling for GITHUB_OUTPUT in workflows

- Write the stdout<<EOF and EOF markers directly to GITHUB_OUTPUT instead of using a group command
- Simplify the process for capturing and appending command output to GITHUB_OUTPUT

fix #403
fix #397

Signed-off-by: appleboy <appleboy.tw@gmail.com>

* test: enhance stdout capture and verification in tests

- Add a check to ensure captured stdout is not empty
- Add steps to capture and verify multiline stdout output
- Add verification that specific lines and the username are present in captured output
- Add steps to handle and verify stdout containing special characters and file paths

Signed-off-by: appleboy <appleboy.tw@gmail.com>

* ci: enforce unique occurrence of lines in multiline output validation

- Add a step to verify that lines "Line 1", "Line 2", and "Line 3" each appear exactly once in the multiline output
- Fail the workflow if any line is missing or duplicated
- Confirm successful validation with a message when no duplicates are found

Signed-off-by: appleboy <appleboy.tw@gmail.com>

---------

Signed-off-by: appleboy <appleboy.tw@gmail.com>
This commit is contained in:
Bo-Yi Wu
2026-01-28 10:18:18 +08:00
committed by GitHub
parent 8e460a28f2
commit 0ff4204d59
2 changed files with 99 additions and 5 deletions

View File

@@ -71,11 +71,9 @@ if ! "${TARGET}" --version; then
fi
echo "======================================="
if [[ "${INPUT_CAPTURE_STDOUT}" == 'true' ]]; then
{
echo 'stdout<<EOF'
"${TARGET}" "$@" | tee -a "${GITHUB_OUTPUT}"
echo 'EOF'
} >>"${GITHUB_OUTPUT}"
echo 'stdout<<EOF' >> "${GITHUB_OUTPUT}"
"${TARGET}" "$@" | tee -a "${GITHUB_OUTPUT}"
echo 'EOF' >> "${GITHUB_OUTPUT}"
else
"${TARGET}" "$@"
fi