Skip to content

Commit d45968b

Browse files
committed
ci: add SSH version testing to GitHub Actions workflow
- Add a new job `testing-drone-ssh-version` to the GitHub Actions workflow - Initialize an SSH server container within the workflow - Capture the container's IP address and store it in the GitHub environment - Execute an SSH command and capture its stdout - Check the captured stdout for the expected version `1.8.0` - Add `version` input to `action.yml` for specifying the drone-ssh version - Set `DRONE_SSH_VERSION` environment variable using the `version` input in `action.yml` Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
1 parent 9ca1cd2 commit d45968b

File tree

2 files changed

+53
-0
lines changed

2 files changed

+53
-0
lines changed

.github/workflows/main.yml

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -722,3 +722,52 @@ jobs:
722722
#!/usr/bin/env bash
723723
set -e
724724
ls /nonexistent
725+
726+
testing-drone-ssh-version:
727+
runs-on: ubuntu-latest
728+
steps:
729+
- name: Checkout code
730+
uses: actions/checkout@v4
731+
732+
- name: create new ssh server
733+
run: |
734+
docker run -d \
735+
--name=openssh-server \
736+
--hostname=openssh-server \
737+
-p 2222:2222 \
738+
-e SUDO_ACCESS=false \
739+
-e PASSWORD_ACCESS=true \
740+
-e USER_PASSWORD=password \
741+
-e USER_NAME=linuxserver.io \
742+
--restart unless-stopped \
743+
lscr.io/linuxserver/openssh-server:latest
744+
docker exec openssh-server sh -c "hostname -i" > ip.txt
745+
echo "REMOTE_HOST<<EOF" >> $GITHUB_ENV
746+
cat ip.txt >> $GITHUB_ENV
747+
echo "EOF" >> $GITHUB_ENV
748+
echo "======= container ip address ========="
749+
cat ip.txt
750+
echo "======================================"
751+
sleep 2
752+
753+
- id: stdout01
754+
name: ssh command with stdout 01
755+
uses: ./
756+
with:
757+
host: ${{ env.REMOTE_HOST }}
758+
username: linuxserver.io
759+
password: password
760+
port: 2222
761+
capture_stdout: true
762+
version: 1.8.0
763+
script: |
764+
#!/usr/bin/env bash
765+
echo "Hello World!"
766+
767+
- name: check stdout 01
768+
run: |
769+
echo "stdout: ${{ steps.stdout01.outputs.stdout }}"
770+
if ! echo "${{ steps.stdout01.outputs.stdout }}" | grep -q "1.8.0"; then
771+
echo "Expected version 1.8.0 not found in output"
772+
exit 1
773+
fi

action.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,9 @@ inputs:
8181
capture_stdout:
8282
description: "When true, captures and returns standard output from the commands as action output."
8383
default: "false"
84+
version:
85+
description: |
86+
The version of drone-ssh to use.
8487
8588
outputs:
8689
stdout:
@@ -135,6 +138,7 @@ runs:
135138
INPUT_SYNC: ${{ inputs.sync }}
136139
INPUT_CAPTURE_STDOUT: ${{ inputs.capture_stdout }}
137140
INPUT_CURL_INSECURE: ${{ inputs.curl_insecure }}
141+
DRONE_SSH_VERSION: ${{ inputs.version }}
138142

139143
branding:
140144
icon: "terminal"

0 commit comments

Comments
 (0)