Files
ax_hub_mcp_tool/.gitea/workflows/deploy.yml
jade 72f04aef62
All checks were successful
Deploy to OCIWP / deploy (push) Successful in 11m35s
fix: remove curl command that fails in act_runner
2026-07-24 23:26:48 +09:00

132 lines
5.3 KiB
YAML
Raw Blame History

name: Deploy to OCIWP
on:
push:
branches:
- main
- master
workflow_dispatch:
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v4
- name: Sync Code to Host Volume
run: |
echo "Cleaning up old src directories to prevent stale source files..."
rm -rf /app/*/src
echo "Copying latest code to /app (Host Volume)..."
cp -a . /app/
- name: Deploy Task on Host
run: |
echo "Starting Blue-Green CI/CD Deploy pipeline..."
# 1. (?<3F>거?? ?<3F>스??볼륨?<3F>서??불필?<3F>한 gradle 빌드 ?<3F>외 - Dockerfile ?<3F>에???<3F><>? ?<3F>행?<3F><>?<3F>?OOM 방<>?)
cd /app
# 3. 블루/그린 ?<3F><>??<3F>
IS_BLUE_RUNNING=$(docker ps --filter "name=ax_hub_mcp_tool-gateway-blue-1" --filter "status=running" -q)
if [ ! -z "$IS_BLUE_RUNNING" ]; then
echo "Current active color is BLUE. Deploying to GREEN..."
TARGET="green"
OLD_TARGET="blue"
else
echo "Current active color is GREEN (or none). Deploying to BLUE..."
TARGET="blue"
OLD_TARGET="green"
fi
# 3.5. 공통 ?<3F>프??(DB, Redis ?? 먼<>? ?<3F><EFBFBD>?(Nginx ?<3F>외)
ACTIVE_PROFILE=dev docker compose up -d redis mci-mock dozzle
# 4. ?<3F>규 버전(TARGET) 컨테?<3F>너 기동
echo "Building and starting $TARGET containers sequentially to prevent OOM..."
ACTIVE_PROFILE=dev docker compose build gateway-$TARGET
ACTIVE_PROFILE=dev docker compose build tool-sms-$TARGET
ACTIVE_PROFILE=dev docker compose build tool-email-$TARGET
ACTIVE_PROFILE=dev docker compose build tool-other-$TARGET
ACTIVE_PROFILE=dev docker compose build tool-payment-$TARGET
ACTIVE_PROFILE=dev docker compose up -d gateway-$TARGET
sleep 5
ACTIVE_PROFILE=dev docker compose up -d tool-sms-$TARGET
sleep 5
ACTIVE_PROFILE=dev docker compose up -d tool-email-$TARGET
sleep 5
ACTIVE_PROFILE=dev docker compose up -d tool-other-$TARGET
sleep 5
ACTIVE_PROFILE=dev docker compose up -d tool-payment-$TARGET
# 4.5. 제거할 컨테이너 (포트 충돌 방지, Nginx 제외)
echo "Finding and killing legacy containers holding our ports..."
for port in 6379 8089 8281 8282 8283 8284 8285 8288; do
cid=$(docker ps -q --filter "publish=$port")
if [ ! -z "$cid" ]; then
echo "Force killing container $cid using port $port"
docker rm -f $cid
fi
done
# 4.6. Nginx 초기 ?정 ?기동
mkdir -p ./nginx/conf.d
echo "Initializing Nginx config to $TARGET..."
cp ./nginx/${TARGET}.conf ./nginx/conf.d/default.conf
ACTIVE_PROFILE=dev docker compose up -d nginx
# 5. Health Check (??버전???상?으??는지 ?인)
echo "Fetching gateway logs..."
docker logs --tail 100 ax_hub_mcp_tool-gateway-$TARGET-1
echo "Waiting 30 seconds for services to fully start..."
sleep 30
# ?규 컨테?너가 죽? ?고 ?아?는지 ?인
IS_TARGET_ALIVE=$(docker ps --filter "name=ax_hub_mcp_tool-gateway-${TARGET}-1" --filter "status=running" -q)
if [ -z "$IS_TARGET_ALIVE" ]; then
echo "Health Check Failed! $TARGET container crashed. Rollback."
echo "Rolling back Nginx config to $OLD_TARGET..."
cp ./nginx/${OLD_TARGET}.conf ./nginx/conf.d/default.conf
echo "Restarting Nginx to apply rollback..."
docker compose restart nginx || true
echo "Stopping failed $TARGET containers..."
docker compose stop gateway-$TARGET tool-sms-$TARGET tool-email-$TARGET tool-other-$TARGET tool-payment-$TARGET
exit 1 # ?<3F>이?<3F>라???<3F>패 처리 (구버?<3F><>? 그<>?<3F>??<3F><>???
fi
# 6. ?<3F>래???<3F>환 (Nginx ?<3F>정 ?<3F><EFBFBD>?
echo "Health Check Passed! Switching traffic to $TARGET..."
mkdir -p ./nginx/conf.d
cp ./nginx/${TARGET}.conf ./nginx/conf.d/default.conf
if ! docker compose exec -T nginx nginx -s reload; then
echo "Nginx reload failed! Rolling back Nginx configuration..."
cp ./nginx/${OLD_TARGET}.conf ./nginx/conf.d/default.conf
docker compose exec -T nginx nginx -s reload || true
echo "Stopping failed $TARGET containers..."
docker compose stop gateway-$TARGET tool-sms-$TARGET tool-email-$TARGET tool-other-$TARGET tool-payment-$TARGET
exit 1
fi
# 7. 구버??종료
echo "Traffic switched successfully. Stopping old $OLD_TARGET containers..."
docker compose stop gateway-$OLD_TARGET tool-sms-$OLD_TARGET tool-email-$OLD_TARGET tool-other-$OLD_TARGET tool-payment-$OLD_TARGET
# 가비<EAB080>? <20>?<3F><>
docker system prune -f
docker image prune -f
echo "Blue-Green CI/CD Deploy Success! Currently running: $TARGET"