113 lines
3.2 KiB
Bash
Executable File
113 lines
3.2 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# 로컬 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)"
|
|
GIT_BRANCH="${GIT_BRANCH:-main}"
|
|
GITEA_REMOTE="${GITEA_REMOTE:-origin}"
|
|
DRY_RUN=false
|
|
|
|
for arg in "$@"; do
|
|
case "$arg" in
|
|
--dry-run) DRY_RUN=true ;;
|
|
-h|--help)
|
|
sed -n '2,10p' "$0"
|
|
exit 0
|
|
;;
|
|
*)
|
|
echo "알 수 없는 옵션: $arg (--help)"
|
|
exit 1
|
|
;;
|
|
esac
|
|
done
|
|
|
|
log() { echo "[push-to-gitea] $*"; }
|
|
warn() { echo "[push-to-gitea] ⚠️ $*" >&2; }
|
|
fail() { log "ERROR: $*"; exit 1; }
|
|
|
|
cd "${ROOT_DIR}"
|
|
|
|
[[ -d .git ]] || fail "Git 저장소 아님: ${ROOT_DIR}"
|
|
|
|
if [[ ! -f .gitmodules ]]; then
|
|
fail ".gitmodules 없음 — submodule 설정 후 다시 실행"
|
|
fi
|
|
|
|
log "공식 GitHub 동기화/push 생략 (Gitea 전용 배포)"
|
|
|
|
# 서버 env.template·overlay와 중복되는 submodule 작업트리 변경은 되돌림
|
|
reset_submodule_noise() {
|
|
local path="$1"
|
|
shift
|
|
[[ -d "${ROOT_DIR}/${path}/.git" ]] || return 0
|
|
local f
|
|
for f in "$@"; do
|
|
if git -C "${ROOT_DIR}/${path}" diff --quiet -- "$f" 2>/dev/null; then
|
|
continue
|
|
fi
|
|
if $DRY_RUN; then
|
|
log "[dry-run] ${path} — 되돌림: $f"
|
|
else
|
|
git -C "${ROOT_DIR}/${path}" checkout -- "$f" 2>/dev/null || true
|
|
fi
|
|
done
|
|
}
|
|
|
|
reset_submodule_noise "exAiChatBot-chatbot2.0-agent" \
|
|
create-offline-package-slim.sh docker-compose-slim.yml \
|
|
env.example env.template scripts/vector_store.py
|
|
reset_submodule_noise "chatbotApi-chatbot2.0-agent" gradlew
|
|
reset_submodule_noise "kakaoChatbotSkill-chatbot2.0-agent" gradlew
|
|
|
|
if $DRY_RUN; then
|
|
log "[dry-run] git add / commit / push 생략"
|
|
git status -sb
|
|
git submodule status || true
|
|
exit 0
|
|
fi
|
|
|
|
chmod +x git_fetch_all.sh server-dev/*.sh 2>/dev/null || true
|
|
chmod +x chatbotApp-chatbot2.0-agent/build.sh 2>/dev/null || true
|
|
|
|
git add .gitmodules
|
|
git add local-dev/ server-dev/ scripts/ git_fetch_all.sh 2>/dev/null || true
|
|
git add start-all-server.sh stop-all-server.sh 2>/dev/null || true
|
|
|
|
for path in chatbotApp-chatbot2.0-agent chatbotApi-chatbot2.0-agent \
|
|
exAiChatBot-chatbot2.0-agent kakaoChatbotSkill-chatbot2.0-agent; do
|
|
[[ -d "${path}" ]] && git add "${path}" 2>/dev/null || true
|
|
done
|
|
|
|
# embedded → submodule 전환 잔여 삭제 반영
|
|
git add -u
|
|
|
|
if ! git diff --cached --quiet; then
|
|
msg="Deploy: exdev sync $(date '+%Y-%m-%d %H:%M:%S')"
|
|
log "monorepo 커밋: ${msg}"
|
|
git commit -m "${msg}"
|
|
else
|
|
log "monorepo 스테이징 변경 없음"
|
|
fi
|
|
|
|
git fetch "${GITEA_REMOTE}" "${GIT_BRANCH}" 2>/dev/null || true
|
|
local_rev="$(git rev-parse HEAD)"
|
|
remote_rev=""
|
|
if git rev-parse "${GITEA_REMOTE}/${GIT_BRANCH}" >/dev/null 2>&1; then
|
|
remote_rev="$(git rev-parse "${GITEA_REMOTE}/${GIT_BRANCH}")"
|
|
fi
|
|
|
|
if [[ -n "${remote_rev}" && "${local_rev}" == "${remote_rev}" ]]; then
|
|
log "✅ Gitea 이미 최신 (${local_rev:0:7})"
|
|
exit 0
|
|
fi
|
|
|
|
log "Gitea push ${GITEA_REMOTE} ${GIT_BRANCH} (${local_rev:0:7})..."
|
|
git push "${GITEA_REMOTE}" "${GIT_BRANCH}"
|
|
log "✅ Gitea push 완료 — post-receive 배포 트리거됨"
|