add docker network
This commit is contained in:
@@ -18,8 +18,9 @@ jobs:
|
||||
|
||||
- name: Run SSH server
|
||||
run: |
|
||||
docker network create test-net || true
|
||||
docker rm -f ssh-server-test || true
|
||||
docker run -d --name ssh-server-test -p 2223:22 -e COMMAND="/bin/sh" ssh-server-test
|
||||
docker run -d --network test-net --name ssh-server-test -e COMMAND="/bin/sh" ssh-server-test
|
||||
sleep 2
|
||||
if ! docker ps | grep -q ssh-server-test; then
|
||||
echo "Container failed to start"
|
||||
@@ -29,16 +30,14 @@ jobs:
|
||||
|
||||
- name: Test SSH connection
|
||||
run: |
|
||||
ip=$(docker inspect ssh-server-test | jq -r '.[0].NetworkSettings.IPAddress')
|
||||
echo "TESTING IP $ip"
|
||||
output=$(ssh -p 22 -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null root@$ip "echo test")
|
||||
output=$(docker run --rm --network test-net alpine sh -c "apk add --no-cache openssh-client >/dev/null 2>&1 && ssh -p 22 -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o ConnectTimeout=10 root@ssh-server-test 'echo test'")
|
||||
if [ "$output" = "test" ]; then
|
||||
echo "SSH connection test passed"
|
||||
else
|
||||
echo "SSH connection test failed"
|
||||
exit 1
|
||||
fi
|
||||
docker stop ssh-server-test && docker rm ssh-server-test
|
||||
docker stop ssh-server-test && docker rm ssh-server-test && docker network rm test-net
|
||||
|
||||
build-and-push:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
Reference in New Issue
Block a user