Files
go-ssh-server/.gitea/workflows/build-and-push.yml
dcorral 55a8b4c86a
Some checks failed
Build, Test and Push Docker Image / e2e-test (push) Failing after 4s
Build, Test and Push Docker Image / build-and-push (push) Has been skipped
Fix action
2025-11-06 20:40:41 +01:00

60 lines
1.5 KiB
YAML

name: Build, Test and Push Docker Image
on:
push:
branches:
- master
jobs:
e2e-test:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Build Docker image
run: docker build -t ssh-server-test .
- name: Run SSH server
run: |
docker run -d --name ssh-server-test -p 2223:22 -e COMMAND="/bin/sh" ssh-server-test
sleep 2
if ! docker ps | grep -q ssh-server-test; then
echo "Container failed to start"
docker logs ssh-server-test
exit 1
fi
- name: Test SSH connection
run: |
output=$(ssh -p 2223 -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null root@localhost "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
build-and-push:
runs-on: ubuntu-latest
needs: e2e-test
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Log in to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_TOKEN }}
- name: Build and push Docker image
uses: docker/build-push-action@v4
with:
context: .
push: true
tags: dcorral3/go-ssh-server-command:latest