8a884e53e3
eapim-admin CI / build (push) Has been cancelled
- DEPLOY_HTTP_PORT 30120 → 39120 (실서버 tomcat 포트) Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
141 lines
5.2 KiB
YAML
141 lines
5.2 KiB
YAML
name: eapim-admin CI
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- master
|
|
- develop
|
|
- stage
|
|
- feats/ci-test
|
|
|
|
jobs:
|
|
build:
|
|
runs-on: [self-hosted, linux, eapim-admin]
|
|
env:
|
|
JAVA_HOME: /apps/opts/jdk8
|
|
JAVA_HOME_TOMCAT: /apps/opts/jdk17
|
|
CATALINA_BASE: /prod/eapim/adminportal
|
|
CATALINA_HOME: /prod/eapim/apache-tomcat-9.0.116
|
|
CATALINA_PID: /prod/eapim/adminportal/temp/catalina.pid
|
|
DEPLOY_HTTP_PORT: "39120"
|
|
defaults:
|
|
run:
|
|
working-directory: eapim-admin
|
|
|
|
steps:
|
|
- name: Checkout eapim-admin (trigger SHA)
|
|
uses: http://172.30.1.50:3000/actions/checkout@v4
|
|
with:
|
|
path: eapim-admin
|
|
|
|
- name: Checkout sibling modules (master)
|
|
working-directory: ${{ github.workspace }}
|
|
run: |
|
|
set -e
|
|
mkdir -p eapim-online
|
|
|
|
# eapim-online/* — 5 modules referenced from settings.gradle
|
|
for REPO in elink-online-core elink-online-core-jpa elink-online-transformer elink-online-common elink-online-emsclient; do
|
|
rm -rf "eapim-online/$REPO"
|
|
git clone --depth=1 --branch master \
|
|
http://oauth2:${{ secrets.CI_TOKEN }}@172.30.1.50:3000/djb-eapim/$REPO.git \
|
|
"eapim-online/$REPO"
|
|
done
|
|
|
|
# standalone siblings
|
|
for REPO in elink-portal-common eapim-admin-djb; do
|
|
rm -rf "$REPO"
|
|
git clone --depth=1 --branch master \
|
|
http://oauth2:${{ secrets.CI_TOKEN }}@172.30.1.50:3000/djb-eapim/$REPO.git \
|
|
"$REPO"
|
|
done
|
|
|
|
- name: Verify toolchain
|
|
run: |
|
|
java -version
|
|
gradle --version
|
|
|
|
- name: Gradle build (no tests)
|
|
run: gradle clean build -x test --no-daemon
|
|
|
|
- name: Upload WAR artifact
|
|
uses: http://172.30.1.50:3000/actions/upload-artifact@v3
|
|
with:
|
|
name: eapim-admin-war-${{ github.sha }}
|
|
path: eapim-admin/build/libs/eapim-admin.war
|
|
if-no-files-found: error
|
|
|
|
- name: Stop tomcat (pre-clean)
|
|
working-directory: ${{ github.workspace }}
|
|
run: |
|
|
# 1) systemd 관리 인스턴스 정지 (이번 워크플로가 띄운 것)
|
|
systemctl --user stop eapim-admin 2>/dev/null || true
|
|
|
|
# 2) systemd 외부 detached 인스턴스 정리
|
|
if [ -f "$CATALINA_PID" ] && kill -0 "$(cat $CATALINA_PID)" 2>/dev/null; then
|
|
JAVA_HOME=$JAVA_HOME_TOMCAT "$CATALINA_HOME/bin/shutdown.sh" 30 -force || true
|
|
for i in $(seq 1 30); do
|
|
[ -f "$CATALINA_PID" ] && kill -0 "$(cat $CATALINA_PID)" 2>/dev/null || break
|
|
sleep 1
|
|
done
|
|
fi
|
|
rm -f "$CATALINA_PID"
|
|
|
|
- name: Deploy war as /monitoring
|
|
working-directory: ${{ github.workspace }}
|
|
run: |
|
|
DEPLOY_DIR="$CATALINA_BASE/webapps"
|
|
rm -rf "$DEPLOY_DIR/monitoring" "$DEPLOY_DIR/monitoring.war"
|
|
cp eapim-admin/build/libs/eapim-admin.war "$DEPLOY_DIR/monitoring.war"
|
|
ls -la "$DEPLOY_DIR"
|
|
|
|
- name: Start tomcat and readiness probe (timeout 300s)
|
|
working-directory: ${{ github.workspace }}
|
|
run: |
|
|
LOG="$CATALINA_BASE/logs/catalina.$(date +%Y-%m-%d).log"
|
|
BEFORE=0
|
|
[ -f "$LOG" ] && BEFORE=$(stat -c %s "$LOG")
|
|
|
|
# systemd 가 Tomcat 을 새 cgroup 으로 띄움 — runner step 종료와 무관하게 살아남음
|
|
systemctl --user start eapim-admin
|
|
|
|
# /loginForm.do 는 GET 매핑(MainController#loginForm) → tomcat·webapp 양쪽 살아있으면 200
|
|
# /login.do 는 POST 처리 — GET 으로 probe 시 405/잘못된 응답 가능성 있어 회피
|
|
PROBE_URL="http://localhost:$DEPLOY_HTTP_PORT/monitoring/loginForm.do"
|
|
DEADLINE=$(($(date +%s) + 300))
|
|
STATUS=000
|
|
while [ $(date +%s) -lt $DEADLINE ]; do
|
|
STATUS=$(curl -sS -o /dev/null -w '%{http_code}' --max-time 3 \
|
|
"$PROBE_URL" 2>/dev/null || echo "000")
|
|
case "$STATUS" in
|
|
200|302|401)
|
|
echo "Readiness OK ($PROBE_URL HTTP $STATUS)"
|
|
break
|
|
;;
|
|
esac
|
|
|
|
if [ -f "$LOG" ] && tail -c +$((BEFORE+1)) "$LOG" | grep -qE "Application listener .* Exception|SEVERE.*startup.Catalina"; then
|
|
echo "::error::Startup error detected in log"
|
|
tail -c +$((BEFORE+1)) "$LOG" | tail -80
|
|
exit 1
|
|
fi
|
|
sleep 2
|
|
done
|
|
|
|
case "$STATUS" in
|
|
200|302|401) ;;
|
|
*)
|
|
echo "::error::Readiness probe failed within 300s (last HTTP status: $STATUS)"
|
|
echo "--- last 300 lines of catalina log ---"
|
|
[ -f "$LOG" ] && tail -c +$((BEFORE+1)) "$LOG" | tail -300
|
|
echo "--- systemd unit status ---"
|
|
systemctl --user status eapim-admin --no-pager || true
|
|
echo "--- listening ports ---"
|
|
ss -tlnp 2>/dev/null | grep -E ":$DEPLOY_HTTP_PORT\b" || echo "(port $DEPLOY_HTTP_PORT 미점유)"
|
|
exit 1
|
|
;;
|
|
esac
|
|
|
|
echo "--- key boot log lines ---"
|
|
tail -c +$((BEFORE+1)) "$LOG" | grep -E "Server startup|Deployment of web" | head -10 || true
|