Checking DB health in github actions

Viewed 32

Im running a container with mssql, and want to know if the DB is healthy after a set of second, cant figure out how to return the value of this step that has the docker inspect command in it

docker inspect --format={{.State.Health.Status}} test-db

so I can tell it in a next step, ex. the output == 'healthy' and if this is true then go forward with the steps onto build down the line..

I dont know the format and my head is starting to explode. If anyone could help me understand how to do this?

EDIT:

I know im close: enter image description here

EDIT: solution was to use those damned single quotes or the $() docker inspect --format={{.State.Health.Status}} test-db

1 Answers

try surrounding the {{ with single quote like

docker inspect --format='{{.State.Health.Status}}' test-db

and executing in the if condition like:

if [[ $(docker inspect --format='{{.State.Health.Status}}' test-db) == "healthy"  ]] 
Related