fix: prevent stdout duplication when capture_stdout is enabled#403
Closed
cyril23 wants to merge 1 commit intoappleboy:masterfrom
Closed
fix: prevent stdout duplication when capture_stdout is enabled#403cyril23 wants to merge 1 commit intoappleboy:masterfrom
cyril23 wants to merge 1 commit intoappleboy:masterfrom
Conversation
The previous implementation wrote command output to GITHUB_OUTPUT twice:
1. Via `tee -a "${GITHUB_OUTPUT}"` directly
2. Via the subshell redirect `} >>"${GITHUB_OUTPUT}"`
This caused every line of captured output to appear twice.
Fix: Change `tee -a "${GITHUB_OUTPUT}"` to `tee /dev/stderr` so that:
- Real-time output is still visible in the Actions log (via stderr)
- Output is only written once to GITHUB_OUTPUT (via subshell redirect)
Owner
|
@cyril23 I will take it. |
pull bot
pushed a commit
to Mu-L/ssh-action
that referenced
this pull request
Jan 28, 2026
…ppleboy#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 appleboy#403 fix appleboy#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 file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fix output duplication bug when
capture_stdout: trueis enabled.Fixes #397
Problem
The bug was introduced in PR #374 (commit b6690ee) during a refactoring. The original implementation was correct:
The refactoring wrapped everything in a subshell but kept
tee -a:This causes command output to be written twice to
GITHUB_OUTPUT:tee -a "${GITHUB_OUTPUT}"directly{ ... } >>"${GITHUB_OUTPUT}"redirectSolution
Change
tee -a "${GITHUB_OUTPUT}"totee /dev/stderr:GITHUB_OUTPUT(via the subshell redirect)Testing
Tested in production CI/CD pipelines deploying to multiple servers. Before the fix, all captured output lines appeared duplicated. After the fix, output appears correctly once.