- .gitea/workflows/deploy.yml: main merge 시 frontend/backend 자동 빌드·배포 - deploy/kcg-backend.service: systemd 서비스 (JDK 17, 2~4GB 힙) - deploy/nginx-kcg.conf: SSL + SPA 서빙 + API 프록시 + 외부 API CORS 프록시 - .githooks/pre-commit: 모노레포 대응 (frontend tsc+eslint, backend mvn compile) - .gitignore: frontend/backend/prediction 각각 빌드 산출물 추가 - CLAUDE.md: 모노레포 구조 반영 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
76 lines
2.2 KiB
YAML
76 lines
2.2 KiB
YAML
name: Deploy KCG
|
|
|
|
on:
|
|
push:
|
|
branches: [main]
|
|
|
|
jobs:
|
|
deploy:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
# ═══ Frontend ═══
|
|
- uses: actions/setup-node@v4
|
|
with:
|
|
node-version: '24'
|
|
|
|
- name: Configure npm registry
|
|
run: |
|
|
echo "registry=https://nexus.gc-si.dev/repository/npm-public/" > frontend/.npmrc
|
|
echo "//nexus.gc-si.dev/repository/npm-public/:_auth=${{ secrets.NEXUS_NPM_AUTH }}" >> frontend/.npmrc
|
|
|
|
- name: Build frontend
|
|
working-directory: frontend
|
|
env:
|
|
VITE_GOOGLE_CLIENT_ID: ${{ secrets.GOOGLE_CLIENT_ID }}
|
|
run: |
|
|
npm ci
|
|
npx vite build
|
|
|
|
- name: Deploy frontend
|
|
run: |
|
|
mkdir -p /deploy/kcg
|
|
rm -rf /deploy/kcg/*
|
|
cp -r frontend/dist/* /deploy/kcg/
|
|
|
|
# ═══ Backend ═══
|
|
- name: Install JDK 17 + Maven
|
|
run: |
|
|
sudo apt-get update -qq
|
|
sudo apt-get install -y -qq openjdk-17-jdk-headless maven
|
|
|
|
- name: Build backend
|
|
working-directory: backend
|
|
run: mvn -B clean package -DskipTests
|
|
|
|
- name: Deploy backend
|
|
run: |
|
|
DEPLOY_DIR=/deploy/kcg-backend
|
|
mkdir -p $DEPLOY_DIR/backup
|
|
|
|
# JAR 백업 (최근 5개 유지)
|
|
if [ -f $DEPLOY_DIR/kcg.jar ]; then
|
|
cp $DEPLOY_DIR/kcg.jar $DEPLOY_DIR/backup/kcg-$(date +%Y%m%d%H%M%S).jar
|
|
ls -t $DEPLOY_DIR/backup/*.jar | tail -n +6 | xargs -r rm
|
|
fi
|
|
|
|
# 서비스 중지 → JAR 교체 → 서비스 시작
|
|
sudo systemctl stop kcg-backend || true
|
|
cp backend/target/kcg.jar $DEPLOY_DIR/kcg.jar
|
|
sudo systemctl start kcg-backend
|
|
|
|
- name: Health check
|
|
run: |
|
|
echo "Waiting for backend to start..."
|
|
for i in $(seq 1 30); do
|
|
HTTP_CODE=$(curl -s -o /dev/null -w "%{http_code}" http://localhost:8080/api/auth/me 2>/dev/null || echo "000")
|
|
if [ "$HTTP_CODE" != "000" ]; then
|
|
echo "Backend is up (HTTP $HTTP_CODE, attempt $i)"
|
|
exit 0
|
|
fi
|
|
sleep 2
|
|
done
|
|
echo "Backend health check failed after 60s"
|
|
exit 1
|