Skip to content

Commit

Permalink
docker health
Browse files Browse the repository at this point in the history
  • Loading branch information
kayprogrammer committed Dec 23, 2024
1 parent 3140b52 commit ee68860
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,20 @@ jobs:
echo "Deployment successful"
EOF
# Step 8: Notify Slack - Success
# Step 8: Verify Container Health
- name: Verify Container Health
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)")
if [[ "$health_status" != "\"healthy\"" ]]; then
echo "API container is unhealthy! Status: $health_status"
exit 1
else
echo "API container is healthy."
fi
# Step 9: Notify Slack - Success
- name: Notify Slack - Success
if: success()
uses: slackapi/[email protected]
Expand All @@ -106,7 +119,7 @@ jobs:
short: true
value: "The latest code was successfully deployed to the VPS."
# Step 9: Notify Slack - Failure
# Step 10: Notify Slack - Failure
- name: Notify Slack - Failure
if: failure()
uses: slackapi/[email protected]
Expand Down

0 comments on commit ee68860

Please sign in to comment.