name: Build and Deploy KCG AI Monitoring (Frontend) on: push: branches: - main paths: - 'frontend/**' jobs: build-and-deploy: runs-on: ubuntu-latest steps: - name: Checkout uses: actions/checkout@v4 - name: Setup Node.js uses: actions/setup-node@v4 with: node-version: '24' - name: Configure npm registry working-directory: frontend run: | echo "registry=https://nexus.gc-si.dev/repository/npm-public/" > .npmrc echo "//nexus.gc-si.dev/repository/npm-public/:_auth=${{ secrets.NEXUS_NPM_AUTH }}" >> .npmrc - name: Install dependencies working-directory: frontend run: npm ci --legacy-peer-deps - name: Build working-directory: frontend run: npm run build - name: Deploy to server run: | mkdir -p /deploy/kcg-ai-monitoring rm -rf /deploy/kcg-ai-monitoring/* cp -r frontend/dist/* /deploy/kcg-ai-monitoring/ echo "Frontend deployed at $(date '+%Y-%m-%d %H:%M:%S')" ls -la /deploy/kcg-ai-monitoring/ - name: Archive system-flow snapshot (per version) run: | # system-flow.html을 manifest version별로 영구 보존 (서버 로컬, nginx 노출 X) ARCHIVE=/deploy/kcg-ai-monitoring-archive/system-flow mkdir -p $ARCHIVE if [ ! -f "frontend/src/flow/manifest/meta.json" ]; then echo "[archive] meta.json not found, skip" exit 0 fi VERSION=$(node -e "console.log(JSON.parse(require('fs').readFileSync('frontend/src/flow/manifest/meta.json')).version)") DATE=$(date +%Y-%m-%d) SNAPSHOT="$ARCHIVE/v${VERSION}_${DATE}" if [ -d "$SNAPSHOT" ]; then echo "[archive] v${VERSION} already exists, skip" exit 0 fi mkdir -p "$SNAPSHOT/assets" cp /deploy/kcg-ai-monitoring/system-flow.html "$SNAPSHOT/" 2>/dev/null || true cp /deploy/kcg-ai-monitoring/assets/systemFlow-*.* "$SNAPSHOT/assets/" 2>/dev/null || true cp /deploy/kcg-ai-monitoring/assets/index-*.* "$SNAPSHOT/assets/" 2>/dev/null || true # manifest 전체 스냅샷 (JSON 형태로 별도 참조 가능) cp -r frontend/src/flow/manifest "$SNAPSHOT/manifest" 2>/dev/null || true echo "[archive] system-flow v${VERSION} snapshot saved → $SNAPSHOT" ls -la "$SNAPSHOT/"