File tree Expand file tree Collapse file tree 3 files changed +64
-2
lines changed Expand file tree Collapse file tree 3 files changed +64
-2
lines changed Original file line number Diff line number Diff line change @@ -549,3 +549,48 @@ jobs:
549
549
#!/usr/bin/env bash
550
550
set -e
551
551
whoami
552
+
553
+ testing-capturing-output :
554
+ runs-on : ubuntu-latest
555
+ steps :
556
+ - name : Checkout code
557
+ uses : actions/checkout@v4
558
+
559
+ - name : create new ssh server
560
+ run : |
561
+ docker run -d \
562
+ --name=openssh-server \
563
+ --hostname=openssh-server \
564
+ -p 2222:2222 \
565
+ -e SUDO_ACCESS=false \
566
+ -e PASSWORD_ACCESS=true \
567
+ -e USER_PASSWORD=password \
568
+ -e USER_NAME=linuxserver.io \
569
+ --restart unless-stopped \
570
+ lscr.io/linuxserver/openssh-server:latest
571
+ docker exec openssh-server sh -c "hostname -i" > ip.txt
572
+ echo "REMOTE_HOST<<EOF" >> $GITHUB_ENV
573
+ cat ip.txt >> $GITHUB_ENV
574
+ echo "EOF" >> $GITHUB_ENV
575
+ echo "======= container ip address ========="
576
+ cat ip.txt
577
+ echo "======================================"
578
+ sleep 2
579
+
580
+ - id : stdout
581
+ name : ssh command with stdout
582
+ uses : ./
583
+ with :
584
+ host : ${{ env.REMOTE_HOST }}
585
+ username : linuxserver.io
586
+ password : password
587
+ port : 2222
588
+ capture_stdout : true
589
+ script : |
590
+ #!/usr/bin/env bash
591
+ set -e
592
+ whoami
593
+
594
+ - name : check stdout
595
+ run : |
596
+ echo "stdout: ${{ steps.stdout.outputs.stdout }}"
Original file line number Diff line number Diff line change @@ -75,6 +75,14 @@ inputs:
75
75
description : " pass all environment variable to shell script."
76
76
request_pty :
77
77
description : " Request a pseudo-terminal from the server."
78
+ capture_stdout :
79
+ description : " Capture the stdout of the commands."
80
+ default : " false"
81
+
82
+ outputs :
83
+ stdout :
84
+ description : ' Standard output of the executed commands.'
85
+ value : ${{ steps.entrypoint.outputs.stdout }}
78
86
79
87
runs :
80
88
using : " composite"
84
92
shell : bash
85
93
env :
86
94
GITHUB_ACTION_PATH : ${{ github.action_path }}
87
- - name : Run entrypoint.sh
95
+ - id : entrypoint
96
+ name : Run entrypoint.sh
88
97
run : entrypoint.sh
89
98
shell : bash
90
99
env :
@@ -121,6 +130,7 @@ runs:
121
130
INPUT_PROXY_USE_INSECURE_CIPHER : ${{ inputs.proxy_use_insecure_cipher }}
122
131
INPUT_PROXY_CIPHER : ${{ inputs.proxy_cipher }}
123
132
INPUT_SYNC : ${{ inputs.sync }}
133
+ INPUT_CAPTURE_STDOUT : ${{ inputs.capture_stdout }}
124
134
125
135
branding :
126
136
icon : " terminal"
Original file line number Diff line number Diff line change @@ -64,7 +64,14 @@ TARGET="${GITHUB_ACTION_PATH}/${CLIENT_BINARY}"
64
64
echo " Will download ${CLIENT_BINARY} from ${DOWNLOAD_URL_PREFIX} "
65
65
curl -fsSL --retry 5 --keepalive-time 2 " ${DOWNLOAD_URL_PREFIX} /${CLIENT_BINARY} " -o ${TARGET}
66
66
chmod +x ${TARGET}
67
+
67
68
echo " ======= CLI Version ======="
68
69
sh -c " ${TARGET} --version" # print version
69
70
echo " ==========================="
70
- sh -c " ${TARGET} $* " # run the command
71
+ if [[ " $INPUT_CAPTURE_STDOUT " == ' true' ]]; then
72
+ echo ' stdout<<EOF' >> $GITHUB_OUTPUT # use heredoc for multiline output
73
+ sh -c " ${TARGET} $* " | tee -a $GITHUB_OUTPUT # run the command
74
+ echo ' EOF' >> $GITHUB_OUTPUT
75
+ else
76
+ sh -c " ${TARGET} $* " # run the command
77
+ fi
You can’t perform that action at this time.
0 commit comments