Workflow to check that containers are running #2
Workflow file for this run
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: Deployment Check | |
on: | |
push: | |
branches: | |
- main | |
pull_request: | |
types: [opened, synchronize, reopened] | |
jobs: | |
docker-compose: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- name: Create .env file | |
run: | | |
cat <<EOF > .env | |
SECRET_KEY="foo" | |
DJANGO_SUPERUSER_USERNAME="bar" | |
DJANGO_SUPERUSER_EMAIL="[email protected]" | |
DJANGO_SUPERUSER_PASSWORD="foobar" | |
POSTGRES_DB="foodb" | |
POSTGRES_USER="bar" | |
POSTGRES_PASSWORD="foobar" | |
EOF | |
- name: Build and up | |
run: docker compose up --build | |
- name: Health-checks | |
run: | | |
services=$(docker-compose ps --services) | |
for service in $services; do | |
status=$(docker inspect -f '{{.State.Health.Status}}' $service) | |
if [ "$status" != "healthy" ]; then | |
echo "$service is not healthy" | |
exit 1 | |
fi | |
done |