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