Skip to content

Commit

Permalink
health
Browse files Browse the repository at this point in the history
  • Loading branch information
kayprogrammer committed Dec 23, 2024
1 parent ee68860 commit 2dfe114
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,16 @@ jobs:
env:
VPS_IP: ${{ secrets.VPS_IP }}
run: |
health_status=$(sshpass -p "${{ secrets.SSH_PASSPHRASE }}" ssh -o StrictHostKeyChecking=no docker@${VPS_IP} "docker inspect --format '{{json .State.Health.Status}}' $(docker ps -q -f name=api)")
health_status=$(sshpass -p "${{ secrets.SSH_PASSPHRASE }}" ssh -o StrictHostKeyChecking=no docker@${VPS_IP} << 'EOF'
container_id=$(docker ps -q -f name=api)
if [ -z "$container_id" ]; then
echo "No container found with name 'api'."
exit 1
else
docker inspect --format '{{json .State.Health.Status}}' "$container_id"
fi
EOF
)
if [[ "$health_status" != "\"healthy\"" ]]; then
echo "API container is unhealthy! Status: $health_status"
exit 1
Expand Down

0 comments on commit 2dfe114

Please sign in to comment.