From a3c6d747c4df986bdf3b2f47d77d60f9b0cf215c Mon Sep 17 00:00:00 2001 From: Jesse Date: Tue, 2 Jan 2024 21:00:45 +0000 Subject: [PATCH 1/3] Include stdout and stderr to file --- action.yml | 5 +++++ entrypoint.sh | 9 ++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/action.yml b/action.yml index 405b14a..6b55ee0 100644 --- a/action.yml +++ b/action.yml @@ -67,6 +67,11 @@ inputs: description: 'Enable debug mode.' allenvs: description: 'pass all environment variable to shell script.' +outputs: + stdout: + description: 'Standard output of the executed commands.' + stderr: + description: 'Standard error of the executed commands.' runs: using: 'docker' image: 'Dockerfile' diff --git a/entrypoint.sh b/entrypoint.sh index f880594..584336a 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -4,4 +4,11 @@ set -eu export GITHUB="true" -sh -c "/bin/drone-ssh $*" +{ + sh -c "/bin/drone-ssh $*" +} 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 From 384d12c1a479148073699ce9036a746b01ff7f38 Mon Sep 17 00:00:00 2001 From: Jesse Date: Tue, 2 Jan 2024 21:20:17 +0000 Subject: [PATCH 2/3] remove stderr --- action.yml | 2 -- entrypoint.sh | 5 ++--- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/action.yml b/action.yml index 6b55ee0..87cffc8 100644 --- a/action.yml +++ b/action.yml @@ -70,8 +70,6 @@ inputs: outputs: stdout: description: 'Standard output of the executed commands.' - stderr: - description: 'Standard error of the executed commands.' runs: using: 'docker' image: 'Dockerfile' diff --git a/entrypoint.sh b/entrypoint.sh index 584336a..e17cbf0 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -1,14 +1,13 @@ #!/bin/sh set -eu +set -o pipefail export GITHUB="true" { sh -c "/bin/drone-ssh $*" -} 2> /tmp/errFile | tee /tmp/outFile +} | 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 From 164b6acc226a30d40ac153b282e57cdf565741ef Mon Sep 17 00:00:00 2001 From: Jesse Date: Tue, 2 Jan 2024 21:49:20 +0000 Subject: [PATCH 3/3] test multiline --- entrypoint.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/entrypoint.sh b/entrypoint.sh index e17cbf0..f20d300 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -9,5 +9,6 @@ export GITHUB="true" sh -c "/bin/drone-ssh $*" } | tee /tmp/outFile -stdout=$(cat /tmp/outFile) -echo "stdout=${stdout//$'\n'/\\n}" >> $GITHUB_OUTPUT +echo "stdout<> $GITHUB_OUTPUT +cat /tmp/outFile >> $GITHUB_OUTPUT +echo "EOF" >> $GITHUB_OUTPUT