mirror of
https://github.com/appleboy/ssh-action.git
synced 2025-03-28 14:46:19 +01:00
ci: add SSH testing job to GitHub Actions workflow
- Add a new job `testing-script-stop` to the GitHub Actions workflow - Set up an SSH server using a Docker container within the new job - Capture the container's IP address and store it in the GitHub environment - Add a step to run an SSH command with stdout capture - Include a script to test conditional logic within the SSH command - Add a step to check and print the captured stdout from the SSH command Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
This commit is contained in:
parent
102c0d2e5f
commit
f439c3d1f1
1 changed files with 50 additions and 0 deletions
50
.github/workflows/main.yml
vendored
50
.github/workflows/main.yml
vendored
|
@ -594,3 +594,53 @@ jobs:
|
||||||
- name: check stdout
|
- name: check stdout
|
||||||
run: |
|
run: |
|
||||||
echo "stdout: ${{ steps.stdout.outputs.stdout }}"
|
echo "stdout: ${{ steps.stdout.outputs.stdout }}"
|
||||||
|
|
||||||
|
testing-script-stop:
|
||||||
|
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
|
||||||
|
|
||||||
|
- id: stdout
|
||||||
|
name: ssh command with stdout
|
||||||
|
uses: ./
|
||||||
|
with:
|
||||||
|
host: ${{ env.REMOTE_HOST }}
|
||||||
|
username: linuxserver.io
|
||||||
|
password: password
|
||||||
|
port: 2222
|
||||||
|
capture_stdout: true
|
||||||
|
script: |
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
set -e
|
||||||
|
echo "TMP TESTING IF"
|
||||||
|
if [[ "2" == "1" ]]; then
|
||||||
|
echo "True"
|
||||||
|
else
|
||||||
|
echo "False"
|
||||||
|
fi
|
||||||
|
|
||||||
|
- name: check stdout
|
||||||
|
run: |
|
||||||
|
echo "stdout: ${{ steps.stdout.outputs.stdout }}"
|
||||||
|
|
Loading…
Add table
Reference in a new issue