fix: mobile server deploy — Jenkins crumb, APK build deps
Jenkins 트리거에 cookie+crumb 세션을 사용하고, 서버 APK 빌드 시 root npm ci를 실행하며 server-setup 스크립트와 Mobile job 설치를 보완한다. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Executable
+74
@@ -0,0 +1,74 @@
|
||||
#!/usr/bin/env bash
|
||||
# exdev 서버 — Phase 1 Mobile 배포 후 1회 설정 (hook·Jenkins·env·재시작)
|
||||
set -euo pipefail
|
||||
|
||||
export PATH="/opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:${PATH:-/usr/bin:/bin}"
|
||||
for prefix in "$HOME/homebrew" /opt/homebrew; do
|
||||
[[ -x "$prefix/bin/brew" ]] && eval "$("$prefix/bin/brew" shellenv)"
|
||||
done
|
||||
|
||||
WORK_TREE="${WORK_TREE:-/Users/aidev/apps/goldenChart}"
|
||||
GIT_HOOK="${GIT_HOOK:-/Volumes/ADATA/git/goldenChart.git/hooks/post-receive}"
|
||||
ENV_FILE="${ENV_FILE:-$WORK_TREE/.env}"
|
||||
|
||||
log() { echo "[server-setup-mobile] $*"; }
|
||||
|
||||
upsert_env() {
|
||||
local key="$1" val="$2"
|
||||
if [[ -f "$ENV_FILE" ]] && grep -q "^${key}=" "$ENV_FILE" 2>/dev/null; then
|
||||
sed -i '' "s|^${key}=.*|${key}=${val}|" "$ENV_FILE"
|
||||
else
|
||||
echo "${key}=${val}" >> "$ENV_FILE"
|
||||
fi
|
||||
}
|
||||
|
||||
log "post-receive hook 업데이트"
|
||||
cp "$WORK_TREE/scripts/post-receive" "$GIT_HOOK"
|
||||
chmod +x "$GIT_HOOK"
|
||||
|
||||
log "Mobile Jenkins job 설치"
|
||||
chmod +x "$WORK_TREE/scripts/"*.sh
|
||||
"$WORK_TREE/scripts/server-install-mobile-jenkins.sh"
|
||||
MOBILE_JOB="${JENKINS_HOME:-$HOME/.jenkins}/jobs/goldenChart-Mobile-Pipeline"
|
||||
mkdir -p "$MOBILE_JOB/builds"
|
||||
echo 1 > "$MOBILE_JOB/nextBuildNumber"
|
||||
|
||||
log ".env Mobile Jenkins 설정"
|
||||
DESKTOP_USER="$(grep '^GC_DESKTOP_JENKINS_USER=' "$ENV_FILE" | cut -d= -f2- || true)"
|
||||
DESKTOP_TOKEN="$(grep '^GC_DESKTOP_JENKINS_TOKEN=' "$ENV_FILE" | cut -d= -f2- || true)"
|
||||
|
||||
upsert_env GC_MOBILE_JENKINS_ENABLED true
|
||||
upsert_env GC_MOBILE_JENKINS_URL http://host.docker.internal:8090
|
||||
upsert_env GC_MOBILE_JENKINS_JOB goldenChart-Mobile-Pipeline
|
||||
upsert_env GC_MOBILE_JENKINS_TRIGGER_TOKEN goldenchart-mobile-build
|
||||
[[ -n "$DESKTOP_USER" ]] && upsert_env GC_MOBILE_JENKINS_USER "$DESKTOP_USER"
|
||||
[[ -n "$DESKTOP_TOKEN" ]] && upsert_env GC_MOBILE_JENKINS_TOKEN "$DESKTOP_TOKEN"
|
||||
|
||||
if ! grep -q '^GC_MOBILE_APP_IOS_TESTFLIGHT_URL=' "$ENV_FILE" 2>/dev/null; then
|
||||
echo '# TestFlight 초대 URL — App Store Connect에서 발급 후 설정' >> "$ENV_FILE"
|
||||
echo 'GC_MOBILE_APP_IOS_TESTFLIGHT_URL=' >> "$ENV_FILE"
|
||||
fi
|
||||
|
||||
log "Docker backend·frontend 재빌드"
|
||||
cd "$WORK_TREE"
|
||||
docker compose up -d --build backend frontend
|
||||
|
||||
log "Mobile Jenkins 빌드 트리거"
|
||||
export GC_MOBILE_JENKINS_URL=http://127.0.0.1:8090
|
||||
export GC_MOBILE_JENKINS_USER="${DESKTOP_USER:-}"
|
||||
export GC_MOBILE_JENKINS_TOKEN="${DESKTOP_TOKEN:-}"
|
||||
"$WORK_TREE/scripts/trigger-mobile-jenkins-build.sh" || log "[WARN] Mobile Jenkins 트리거 실패"
|
||||
|
||||
if command -v pod >/dev/null 2>&1 && [[ -f "$WORK_TREE/app/ios/App/Podfile" ]]; then
|
||||
log "iOS pod install"
|
||||
(cd "$WORK_TREE/app/ios/App" && pod install) || log "[WARN] pod install 실패"
|
||||
else
|
||||
log "CocoaPods 없음 — iOS 빌드는 brew install cocoapods 후 pod install"
|
||||
fi
|
||||
|
||||
log "API 확인"
|
||||
sleep 4
|
||||
curl -fsSL http://127.0.0.1:8080/api/mobile-app/info 2>/dev/null | python3 -m json.tool 2>/dev/null || \
|
||||
curl -fsSL http://exdev.co.kr/api/mobile-app/info | python3 -m json.tool 2>/dev/null || true
|
||||
|
||||
log "완료"
|
||||
Reference in New Issue
Block a user