mirror of
https://github.com/appleboy/ssh-action.git
synced 2025-01-10 18:15:19 +00:00
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 <appleboy.tw@gmail.com>
This commit is contained in:
parent
66aa4d343b
commit
86aa40ddb7
41
.github/workflows/main.yml
vendored
41
.github/workflows/main.yml
vendored
@ -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<<EOF" >> $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
|
||||
|
Loading…
Reference in New Issue
Block a user