Deploy: exdev sync 2026-07-28 09:40:42

This commit is contained in:
Macbook
2026-07-28 09:40:42 +09:00
parent f85e4adc35
commit 1ee28f3a4d
8 changed files with 41 additions and 59 deletions
+5 -2
View File
@@ -1,7 +1,10 @@
#!/usr/bin/env bash
# 4개 submodule: GitHub chatbot2.0-agent 동기화 → 로컬 변경 commit → push
# 4개 submodule: 로컬 변경 → 공식 GitHub chatbot2.0-agent commit + push
#
# ./git_fetch_all.sh # fetch/merge + commit + push
# ★ 공식 GitHub(KoreaExpressWayCorp) 반영은 이 스크립트로만 수행한다.
# start-all-server.sh / push-to-gitea.sh 는 개발서버(Gitea/exdev)만 다룬다.
#
# ./git_fetch_all.sh # fetch/merge + commit + push (공식 GitHub)
# ./git_fetch_all.sh --init # submodule 미초기화 시 clone 포함
# ./git_fetch_all.sh --dry-run # 실행 없이 상태만 출력
# ./git_fetch_all.sh --no-push # commit까지, push 생략
+6 -2
View File
@@ -52,7 +52,10 @@ Gitea(`https://github.exdev.co.kr`)에서 **`exAichatbot_agent`** 저장소 생
```bash
./start-all-server.sh
# = git_fetch_all (GitHub) → push-to-gitea → post-receive 배포 대기
# = 로컬 빌드 → Gitea(exdev) push → 원격 배포 (공식 GitHub push 없음)
./git_fetch_all.sh
# = 확인 후 공식 GitHub(KoreaExpressWayCorp) 반영 전용
```
| 옵션 | 설명 |
@@ -69,7 +72,8 @@ Gitea(`https://github.exdev.co.kr`)에서 **`exAichatbot_agent`** 저장소 생
./server-dev/push-to-gitea.sh --dry-run
```
**main push 시 자동:** `post-receive` → `deploy-exAichatbot_agent.sh` → checkout + `git_fetch_all --init` → `start-all-server.sh --no-pull --no-push`
**main push 시 자동:** `post-receive` → `deploy-exAichatbot_agent.sh` → Gitea checkout → `start-all-server.sh --no-pull --no-push`
(공식 GitHub `git_fetch_all` 은 deploy 경로에서 호출하지 않음)
서버에서 GitHub clone 이 안 되면 **로컬 `./start-all-server.sh`** 가 submodule rsync + chatbotApp 로컬 빌드 후 배포합니다.
+5 -8
View File
@@ -64,26 +64,23 @@ sync_worktree_submodules() {
fi
done
if [[ ${ready} -ge 4 ]]; then
log "submodule 소스 이미 존재 (rsync 또는 clone 완료) — GitHub fetch 생략"
log "submodule 소스 이미 존재 (Gitea/rsync) — 공식 GitHub fetch 생략"
if [[ -f "${tree}/server-dev/docker-compose.rag.server.yml" ]]; then
cp "${tree}/server-dev/docker-compose.rag.server.yml" \
"${tree}/exAiChatBot-chatbot2.0-agent/docker-compose.server.yml" 2>/dev/null || true
fi
return 0
fi
if [[ -x "${tree}/git_fetch_all.sh" ]]; then
log "GitHub submodule 동기화 (git_fetch_all.sh --init)..."
MONOREPO_GIT_DIR="${GIT_DIR}" "${tree}/git_fetch_all.sh" --init || log "[WARN] git_fetch_all 실패 — 로컬 rsync 필요"
else
log "[WARN] git_fetch_all.sh 없음 — 로컬 rsync 필요"
fi
# 공식 GitHub 는 deploy 경로에서 절대 동기화/push 하지 않음.
# 소스가 비어 있으면 로컬 Mac 의 rsync (sync-submodules-rsync.sh) 가 필요.
log "[WARN] submodule 소스 부족 (${ready}/4) — 공식 GitHub fetch 안 함. 로컬 rsync 필요"
}
log "[Phase 1] stop-all-server.sh"
"$WORK_TREE/server-dev/stop-all-server.sh" --keep-caddy || true
if ! $START_ONLY; then
log "[Phase 2] checkout + GitHub submodule"
log "[Phase 2] checkout (Gitea work tree) — 공식 GitHub 미사용"
git --work-tree="$WORK_TREE" --git-dir="$GIT_DIR" checkout -f "$BRANCH"
rm -f "$WORK_TREE/.git"
sync_worktree_submodules "$WORK_TREE"
+7 -13
View File
@@ -1,8 +1,11 @@
#!/usr/bin/env bash
# 로컬 monorepo + GitHub submodule 포인터 → Gitea push (post-receive 배포 트리거)
# 로컬 monorepo(현재 소스) → Gitea push (post-receive / 원격 배포 트리거)
#
# ./server-dev/push-to-gitea.sh
# ./server-dev/push-to-gitea.sh --dry-run
#
# 공식 GitHub(KoreaExpressWayCorp) 에는 push 하지 않음.
# 공식 GitHub 반영은 ./git_fetch_all.sh 전용.
set -euo pipefail
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
@@ -14,7 +17,7 @@ for arg in "$@"; do
case "$arg" in
--dry-run) DRY_RUN=true ;;
-h|--help)
sed -n '2,6p' "$0"
sed -n '2,10p' "$0"
exit 0
;;
*)
@@ -36,16 +39,7 @@ if [[ ! -f .gitmodules ]]; then
fail ".gitmodules 없음 — submodule 설정 후 다시 실행"
fi
if [[ -x "${ROOT_DIR}/git_fetch_all.sh" ]]; then
log "GitHub submodule 동기화..."
if ! $DRY_RUN; then
"${ROOT_DIR}/git_fetch_all.sh"
else
"${ROOT_DIR}/git_fetch_all.sh" --dry-run
fi
else
warn "git_fetch_all.sh 없음 — submodule GitHub 동기화 생략"
fi
log "공식 GitHub 동기화/push 생략 (Gitea 전용 배포)"
# 서버 env.template·overlay와 중복되는 submodule 작업트리 변경은 되돌림
reset_submodule_noise() {
@@ -94,7 +88,7 @@ done
git add -u
if ! git diff --cached --quiet; then
msg="Deploy: GitHub submodule sync $(date '+%Y-%m-%d %H:%M:%S')"
msg="Deploy: exdev sync $(date '+%Y-%m-%d %H:%M:%S')"
log "monorepo 커밋: ${msg}"
git commit -m "${msg}"
else
+15 -31
View File
@@ -9,6 +9,9 @@
# ./server-dev/start-all-server.sh --no-pull # git 동기화 생략
# ./server-dev/start-all-server.sh --no-push # Gitea push 생략
# ./server-dev/start-all-server.sh --local # 로컬 Mac 개발 모드 (local-dev 위임)
#
# 로컬 Mac 실행 시: 현재 소스 → 개발서버(Gitea/exdev)만 반영·배포.
# 공식 GitHub(KoreaExpressWayCorp) push 는 하지 않음 — ./git_fetch_all.sh 전용.
set -euo pipefail
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
@@ -82,29 +85,8 @@ log() { echo "[$(date '+%H:%M:%S')] $*"; }
fail() { log "ERROR: $*"; exit 1; }
warn() { log "⚠️ $*"; }
sync_github_submodules() {
local tree="$1"
local fetch_script="${tree}/git_fetch_all.sh"
local -a fetch_args=()
if is_exdev_server; then
fetch_args+=(--init)
fi
if [[ ! -x "${fetch_script}" ]]; then
log "git_fetch_all.sh 없음 — submodule GitHub 동기화 생략"
return 0
fi
log "GitHub submodule 최신 동기화 (git_fetch_all.sh)..."
if [[ ${#fetch_args[@]} -gt 0 ]]; then
if ! "${fetch_script}" "${fetch_args[@]}"; then
warn "GitHub submodule 동기화 실패 — ./git_fetch_all.sh 수동 실행"
return 1
fi
elif ! "${fetch_script}"; then
warn "GitHub submodule 동기화 실패 — ./git_fetch_all.sh 수동 실행"
return 1
fi
return 0
}
# 공식 GitHub 동기화/push 는 start-all-server 경로에서 절대 수행하지 않음.
# (과거: git_fetch_all.sh 호출 → 로컬 수정이 공식 GitHub 로 올라가던 문제 방지)
push_source_to_gitea() {
if $NO_PUSH; then
@@ -186,10 +168,8 @@ build_desktop_app() {
}
deploy_from_local_mac() {
log "로컬 Mac → Gitea push → chatbot.exdev.co.kr 배포"
if ! $NO_PULL; then
sync_github_submodules "${ROOT_DIR}" || true
fi
log "로컬 Mac → Gitea(exdev) push → chatbot.exdev.co.kr 배포"
log "공식 GitHub push 생략 (필요 시 ./git_fetch_all.sh)"
build_chatbot_app_for_deploy
push_source_to_gitea
trigger_remote_deploy
@@ -218,19 +198,23 @@ sync_source_from_git() {
fail "브랜치 없음: ${branch} (GIT_DIR=${GIT_DIR})"
fi
git --work-tree="${tree}" --git-dir="${GIT_DIR}" checkout -f "${branch}"
sync_github_submodules "${tree}" || true
# Gitea work tree 만 사용 — 공식 GitHub fetch/push 없음
if [[ -f "${tree}/.gitmodules" ]]; then
log "Gitea submodule 포인터 checkout..."
git -C "${tree}" submodule update --init --recursive 2>/dev/null || \
warn "submodule update 실패 — rsync/배포 산출물로 계속"
fi
local commit
commit="$(git --git-dir="${GIT_DIR}" rev-parse --short HEAD)"
log "✅ 소스 동기화: ${commit} (${branch})"
log "✅ 소스 동기화(Gitea): ${commit} (${branch})"
elif [[ -d "${ROOT_DIR}/.git" ]]; then
log "git pull origin ${branch}..."
log "git pull origin ${branch} (Gitea/monorepo)..."
(
cd "${ROOT_DIR}"
git fetch origin "${branch}"
git checkout "${branch}"
git pull --ff-only origin "${branch}"
)
sync_github_submodules "${ROOT_DIR}" || true
log "✅ git pull 완료: $(git -C "${ROOT_DIR}" rev-parse --short HEAD)"
tree="${ROOT_DIR}"
else