Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -79,3 +79,29 @@ jobs:
docker images -q ${{ secrets.DOCKER_USERNAME }}/${{ secrets.DOCKER_REPOSITORY }}:latest && docker rmi ${{ secrets.DOCKER_USERNAME }}/${{ secrets.DOCKER_REPOSITORY }}:latest
docker pull ${{ secrets.DOCKER_USERNAME }}/${{ secrets.DOCKER_REPOSITORY }}:latest
sudo docker-compose up -d

- name: Health Check
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.GCP_VM_IP }}
username: ${{ secrets.GCP_USERNAME }}
key: ${{ secrets.GCP_SSH_PRIVATE_KEY }}
envs: GITHUB_SHA
script: |
echo "Health check for Spring application"

MAX_ATTEMPTS=10
INTERVAL=10

for i in $(seq 1 $MAX_ATTEMPTS); do
status=$(curl -s -o /dev/null -w "%{http_code}" http://localhost:8080/actuator/health)
if [ "$status" = "200" ]; then
echo "Health check success"
exit 0
fi
echo "Attempt $i/$MAX_ATTEMPTS failed (HTTP $status), waiting 10s..."
sleep $INTERVAL
done

echo "Health check failed"
exit 1
11 changes: 11 additions & 0 deletions src/main/resources/application-local.yml
Original file line number Diff line number Diff line change
Expand Up @@ -110,3 +110,14 @@ server:
threads:
min-spare: 10
max: 200

management:
endpoint:
health:
enabled: true
prometheus:
enabled: true
endpoints:
web:
exposure:
include: health, prometheus
4 changes: 3 additions & 1 deletion src/main/resources/application-prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,11 @@ server:

management:
endpoint:
health:
enabled: true
prometheus:
enabled: true
endpoints:
web:
exposure:
include: prometheus
include: health, prometheus
Loading