Merge pull request #6 from shampiniony/custom-user-auth #95
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Docker Compose CI | |
on: | |
push: | |
workflow_dispatch: | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v2 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v1 | |
- name: Set up Docker Compose | |
uses: docker/setup-qemu-action@v1 | |
- name: Set up Docker Compose | |
run: sudo apt-get install docker-compose | |
- name: Build and start containers | |
run: | | |
cd backend | |
cp .env.example .env | |
docker-compose up -d --build | |
- name: Wait for services to be up | |
run: | | |
echo "Waiting for services to be up..." | |
sleep 30 | |
- name: Check Docker Compose Services | |
run: | | |
cd backend | |
docker-compose ps | |
- name: Check for unhealthy services and restarts | |
run: | | |
cd backend | |
services=$(docker-compose ps --services) | |
for service in $services; do | |
container_id=$(docker-compose ps -q $service) | |
health_status=$(docker inspect --format='{{if .State.Health}}{{.State.Health.Status}}{{else}}no-health-check{{end}}' $container_id) | |
restart_count=$(docker inspect --format='{{.RestartCount}}' $container_id) | |
echo "Service: $service, Health: $health_status, Restarts: $restart_count" | |
if [[ "$health_status" != "healthy" && "$health_status" != "no-health-check" ]]; then | |
echo "Error: Service $service is not healthy" | |
docker-compose logs $service | |
exit 1 | |
fi | |
if [[ "$restart_count" -gt 0 ]]; then | |
echo "Error: Service $service has restarted $restart_count times" | |
docker-compose logs $service | |
exit 1 | |
fi | |
done | |
- name: Stop and remove Docker Compose services | |
run: | | |
cd backend | |
docker-compose down |