From 86aa40ddb7d085faad449ea3e1726b81949ef86b Mon Sep 17 00:00:00 2001 From: Bo-Yi Wu Date: Fri, 3 Jan 2025 09:31:39 +0800 Subject: [PATCH] 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 --- .github/workflows/main.yml | 41 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 3d51589..7737940 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -681,3 +681,44 @@ jobs: if echo "${{ steps.stdout02.outputs.stdout }}" | grep -q "True"; then echo "Output contains 'True'" fi + + testing-script-error: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: create new ssh server + run: | + docker run -d \ + --name=openssh-server \ + --hostname=openssh-server \ + -p 2222:2222 \ + -e SUDO_ACCESS=false \ + -e PASSWORD_ACCESS=true \ + -e USER_PASSWORD=password \ + -e USER_NAME=linuxserver.io \ + --restart unless-stopped \ + lscr.io/linuxserver/openssh-server:latest + docker exec openssh-server sh -c "hostname -i" > ip.txt + echo "REMOTE_HOST<> $GITHUB_ENV + cat ip.txt >> $GITHUB_ENV + echo "EOF" >> $GITHUB_ENV + echo "======= container ip address =========" + cat ip.txt + echo "======================================" + sleep 2 + + - name: test script error + uses: ./ + continue-on-error: true + with: + host: ${{ env.REMOTE_HOST }} + username: linuxserver.io + password: password + port: 2222 + capture_stdout: true + script: | + #!/usr/bin/env bash + set -e + ls /nonexistent