Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Capture stdout and store as output #287

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 6 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,12 @@ inputs:
request_pty:
description: "Request a pseudo-terminal from the server."

outputs:
stdout:
description: 'Standard output of the executed commands.'
stderr:
description: 'Standard error of the executed commands.'

runs:
using: "composite"
steps:
Expand Down
10 changes: 9 additions & 1 deletion entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -63,4 +63,12 @@ TARGET="${GITHUB_ACTION_PATH}/${CLIENT_BINARY}"
echo "Will download ${CLIENT_BINARY} from ${DOWNLOAD_URL_PREFIX}"
curl -fL --retry 3 --keepalive-time 2 "${DOWNLOAD_URL_PREFIX}/${CLIENT_BINARY}" -o ${TARGET}
chmod +x ${TARGET}
sh -c "${TARGET} $*"

{
sh -c "${TARGET} $*"
} 2> /tmp/errFile | tee /tmp/outFile

stdout=$(cat /tmp/outFile)
stderr=$(cat /tmp/errFile)
echo "stdout=${stdout//$'\n'/\\n}" >> $GITHUB_OUTPUT
echo "stderr=${stderr//$'\n'/\\n}" >> $GITHUB_OUTPUT