File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -37,14 +37,13 @@ jobs:
3737 set -e
3838 cd ~/deploy
3939
40- echo "🔍 Detecting active container..."
40+ echo "🔍 Reading active slot..."
41+ ACTIVE=$(cat active-slot.txt)
4142
42- if docker ps --filter "name=concert-spring-blue" --format "{{.Status}}" | grep -q healthy; then
43- ACTIVE=blue
43+ if [ "$ACTIVE" = "blue" ]; then
4444 TARGET=green
4545 PORT=8082
4646 else
47- ACTIVE=green
4847 TARGET=blue
4948 PORT=8081
5049 fi
@@ -68,12 +67,20 @@ jobs:
6867 echo "⏳ still waiting..."
6968 sleep 5
7069 done
71-
72- if [ "$HEALTHY" = "true" ]; then
73- echo "✅ spring-$TARGET is healthy"
74- exit 0
70+
71+ if [ "$HEALTHY" != "true" ]; then
72+ echo "❌ Health check failed for spring-$TARGET - rolling back"
73+ docker compose -f docker-compose-prod.yml stop spring-$TARGET
74+ exit 1
7575 fi
76-
77- echo "❌ Health check failed for spring-$TARGET - rolling back"
78- docker compose -f docker-compose-prod.yml stop spring-$TARGET
79- exit 1
76+
77+ echo "✅ spring-$TARGET is healthy"
78+
79+ echo "🔀 (MANUAL) Switch NPM forward port to $PORT"
80+ echo "✍️ Update active slot"
81+ echo "$TARGET" > active-slot.txt
82+
83+ echo "🛑 Stop old container : spring-$ACTIVE"
84+ docker compose -f docker-compose-prod.yml stop spring-$ACTIVE
85+
86+ echo "🎉 Blue/Green deployment completed"
You can’t perform that action at this time.
0 commit comments