Skip to content

Commit 86aa40d

Browse files
committed
ci: add SSH server testing to GitHub Actions workflow
- Add a new job `testing-script-error` to the GitHub Actions workflow - Use `actions/checkout@v4` to check out the code - Create and run a new SSH server container using `lscr.io/linuxserver/openssh-server:latest` - Capture the container's IP address and set it as an environment variable - Add a step to test script errors with `continue-on-error: true` - Configure the test script to connect to the SSH server and run a command that will fail (`ls /nonexistent`) Signed-off-by: Bo-Yi Wu <[email protected]>
1 parent 66aa4d3 commit 86aa40d

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed

.github/workflows/main.yml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -681,3 +681,44 @@ jobs:
681681
if echo "${{ steps.stdout02.outputs.stdout }}" | grep -q "True"; then
682682
echo "Output contains 'True'"
683683
fi
684+
685+
testing-script-error:
686+
runs-on: ubuntu-latest
687+
steps:
688+
- name: Checkout code
689+
uses: actions/checkout@v4
690+
691+
- name: create new ssh server
692+
run: |
693+
docker run -d \
694+
--name=openssh-server \
695+
--hostname=openssh-server \
696+
-p 2222:2222 \
697+
-e SUDO_ACCESS=false \
698+
-e PASSWORD_ACCESS=true \
699+
-e USER_PASSWORD=password \
700+
-e USER_NAME=linuxserver.io \
701+
--restart unless-stopped \
702+
lscr.io/linuxserver/openssh-server:latest
703+
docker exec openssh-server sh -c "hostname -i" > ip.txt
704+
echo "REMOTE_HOST<<EOF" >> $GITHUB_ENV
705+
cat ip.txt >> $GITHUB_ENV
706+
echo "EOF" >> $GITHUB_ENV
707+
echo "======= container ip address ========="
708+
cat ip.txt
709+
echo "======================================"
710+
sleep 2
711+
712+
- name: test script error
713+
uses: ./
714+
continue-on-error: true
715+
with:
716+
host: ${{ env.REMOTE_HOST }}
717+
username: linuxserver.io
718+
password: password
719+
port: 2222
720+
capture_stdout: true
721+
script: |
722+
#!/usr/bin/env bash
723+
set -e
724+
ls /nonexistent

0 commit comments

Comments
 (0)