BurningTimesAi/scripts/nas_post_receive.sh

120 lines
4.2 KiB
Bash
Raw Permalink Normal View History

#!/bin/bash
# ─────────────────────────────────────────────────────────────
feat(BT·신설): 조직 신설 Phase 1 — git 저장소 교체 + 중앙 저장소 A안 분리 PD님 2026-04-21 직접 지시 5개 중 1·2·4 이행. ## 집행 내역 1. git remote: NerdNavisAi.git → BurningTimesAi.git 교체 (BT main + 본 worktree) - E:/NerdNavisAi 레포 원격은 원상 유지 (실측 확인) 2. 중앙 저장소 A안 분리: ~/.claude/burningtimes-{live,memory,audit}/ - nerdnavis-* 중앙 저장소에서 cp -r 복사 (원본 미변경) - .junction-marker 내용 BT로 갱신 3. 본 worktree .live junction 재연결 → burningtimes-live 4. audit junction 3종 신설: .burningtimes_{auditor_calls,warning_ignored,bypass_log} 5. scripts·setup 28파일 하드코딩 일괄 치환 (nerdnavis/NerdNavis/너드나비스/NERDNAVIS → burningtimes/BurningTimes/BURNINGTIMES) 6. paths.local.json.template BT 전용 재작성 (Unity·Framework 경로 __TBD__ placeholder) 7. .gitignore: .live.bak_*/ 패턴 추가 ## 보류 항목 (PD 재논의 예정) - 3. memory/org/ 내용 초기화 (PD 지시) - 5. Unity 프로젝트 경로 (PD 신규 경로 제공 전까지) - SKILL.md·CLAUDE.md 조직명 전환 및 P17·P29 처리 - 프로젝트/수상한잡화점/ 등 수상한잡화점 관련 일괄 정리 - 코어코드/NerdNavis.Framework/ → BT-프레임워크 이름 전환 - 공유/조직공지/ 너드나비스 맥락 공지 처리 - .claude/agents/*.md frontmatter skills 참조명 ## 감사 pm-auditor 사전 감사 통과 (Critical 0건, Major 2건 commit 전 정정 완료). 매니페스트: bt-org-split-phase1 (C35-9 PreToolUse 차단 해제). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-20 15:14:51 +00:00
# BurningTimes — NAS git 서버측 post-receive hook
# Phase 3 (2026-04-15 PD님 승인)
#
# 목적: git push 도달 즉시 Discord 채널로 실시간 알림 발송
# → 부서 세션이 구동되지 않은 상태에서도 PD님·PM·부서가 push 이벤트를 즉시 인지
#
# 배치 위치: <NAS bare repo 경로>/hooks/post-receive
feat(BT·신설): 조직 신설 Phase 1 — git 저장소 교체 + 중앙 저장소 A안 분리 PD님 2026-04-21 직접 지시 5개 중 1·2·4 이행. ## 집행 내역 1. git remote: NerdNavisAi.git → BurningTimesAi.git 교체 (BT main + 본 worktree) - E:/NerdNavisAi 레포 원격은 원상 유지 (실측 확인) 2. 중앙 저장소 A안 분리: ~/.claude/burningtimes-{live,memory,audit}/ - nerdnavis-* 중앙 저장소에서 cp -r 복사 (원본 미변경) - .junction-marker 내용 BT로 갱신 3. 본 worktree .live junction 재연결 → burningtimes-live 4. audit junction 3종 신설: .burningtimes_{auditor_calls,warning_ignored,bypass_log} 5. scripts·setup 28파일 하드코딩 일괄 치환 (nerdnavis/NerdNavis/너드나비스/NERDNAVIS → burningtimes/BurningTimes/BURNINGTIMES) 6. paths.local.json.template BT 전용 재작성 (Unity·Framework 경로 __TBD__ placeholder) 7. .gitignore: .live.bak_*/ 패턴 추가 ## 보류 항목 (PD 재논의 예정) - 3. memory/org/ 내용 초기화 (PD 지시) - 5. Unity 프로젝트 경로 (PD 신규 경로 제공 전까지) - SKILL.md·CLAUDE.md 조직명 전환 및 P17·P29 처리 - 프로젝트/수상한잡화점/ 등 수상한잡화점 관련 일괄 정리 - 코어코드/NerdNavis.Framework/ → BT-프레임워크 이름 전환 - 공유/조직공지/ 너드나비스 맥락 공지 처리 - .claude/agents/*.md frontmatter skills 참조명 ## 감사 pm-auditor 사전 감사 통과 (Critical 0건, Major 2건 commit 전 정정 완료). 매니페스트: bt-org-split-phase1 (C35-9 PreToolUse 차단 해제). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-20 15:14:51 +00:00
# 예: /volume1/git-repos/BurningTimesAi.git/hooks/post-receive
# 배치 후: chmod +x post-receive
#
# 환경변수 파일: 같은 hooks/ 디렉토리에 post-receive-env 파일 생성 후 다음 변수 정의
# PM_WEBHOOK_URL — #pm-inbox Discord webhook URL
# DEV_WEBHOOK_URL — #dev-inbox
# PLAN_WEBHOOK_URL — #plan-inbox
# ALL_WEBHOOK_URL — #core-rules (전 조직 공지·코어룰 변경)
#
# 예:
# PM_WEBHOOK_URL="https://discord.com/api/webhooks/1234.../abcd..."
# DEV_WEBHOOK_URL="https://discord.com/api/webhooks/5678.../efgh..."
# PLAN_WEBHOOK_URL="https://discord.com/api/webhooks/9012.../ijkl..."
# ALL_WEBHOOK_URL="https://discord.com/api/webhooks/3456.../mnop..."
#
# chmod 600 post-receive-env (읽기 권한 제한, C6 준수)
# ─────────────────────────────────────────────────────────────
HOOK_DIR=$(dirname "$0")
ENV_FILE="$HOOK_DIR/post-receive-env"
[ -f "$ENV_FILE" ] && source "$ENV_FILE"
# 로그 파일 (디버깅용)
LOG_FILE="$HOOK_DIR/post-receive.log"
log() {
echo "[$(date -Iseconds)] $*" >> "$LOG_FILE" 2>/dev/null
}
send_discord() {
local URL="$1"
local TITLE="$2"
local DESC="$3"
local COLOR="${4:-3447003}" # 기본 파란색
[ -z "$URL" ] && return
# Discord embed payload
local PAYLOAD
PAYLOAD=$(cat <<EOF
{
"embeds": [{
"title": "$TITLE",
"description": "$DESC",
"color": $COLOR,
feat(BT·신설): 조직 신설 Phase 1 — git 저장소 교체 + 중앙 저장소 A안 분리 PD님 2026-04-21 직접 지시 5개 중 1·2·4 이행. ## 집행 내역 1. git remote: NerdNavisAi.git → BurningTimesAi.git 교체 (BT main + 본 worktree) - E:/NerdNavisAi 레포 원격은 원상 유지 (실측 확인) 2. 중앙 저장소 A안 분리: ~/.claude/burningtimes-{live,memory,audit}/ - nerdnavis-* 중앙 저장소에서 cp -r 복사 (원본 미변경) - .junction-marker 내용 BT로 갱신 3. 본 worktree .live junction 재연결 → burningtimes-live 4. audit junction 3종 신설: .burningtimes_{auditor_calls,warning_ignored,bypass_log} 5. scripts·setup 28파일 하드코딩 일괄 치환 (nerdnavis/NerdNavis/너드나비스/NERDNAVIS → burningtimes/BurningTimes/BURNINGTIMES) 6. paths.local.json.template BT 전용 재작성 (Unity·Framework 경로 __TBD__ placeholder) 7. .gitignore: .live.bak_*/ 패턴 추가 ## 보류 항목 (PD 재논의 예정) - 3. memory/org/ 내용 초기화 (PD 지시) - 5. Unity 프로젝트 경로 (PD 신규 경로 제공 전까지) - SKILL.md·CLAUDE.md 조직명 전환 및 P17·P29 처리 - 프로젝트/수상한잡화점/ 등 수상한잡화점 관련 일괄 정리 - 코어코드/NerdNavis.Framework/ → BT-프레임워크 이름 전환 - 공유/조직공지/ 너드나비스 맥락 공지 처리 - .claude/agents/*.md frontmatter skills 참조명 ## 감사 pm-auditor 사전 감사 통과 (Critical 0건, Major 2건 commit 전 정정 완료). 매니페스트: bt-org-split-phase1 (C35-9 PreToolUse 차단 해제). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-20 15:14:51 +00:00
"footer": {"text": "BurningTimes git server · post-receive"}
}]
}
EOF
)
curl -s -X POST "$URL" \
-H "Content-Type: application/json" \
-d "$PAYLOAD" > /dev/null 2>&1
log "sent to $TITLE"
}
json_escape() {
# 최소한의 JSON 이스케이프 (backslash, quote, newline)
printf '%s' "$1" | sed 's/\\/\\\\/g; s/"/\\"/g' | tr '\n' ' '
}
while read oldrev newrev refname; do
# main 브랜치 push만 처리
branch=$(git rev-parse --symbolic --abbrev-ref "$refname" 2>/dev/null)
[ "$branch" != "main" ] && continue
# 최초 push (oldrev가 0...0) 스킵
[[ "$oldrev" =~ ^0+$ ]] && continue
# 변경 파일 목록
CHANGED=$(git diff --name-only "$oldrev" "$newrev" 2>/dev/null)
[ -z "$CHANGED" ] && continue
# 최근 커밋 요약
COMMIT_MSG=$(git log -1 --format="%s" "$newrev" 2>/dev/null)
AUTHOR=$(git log -1 --format="%an" "$newrev" 2>/dev/null)
SHORT_SHA=$(git rev-parse --short "$newrev" 2>/dev/null)
COMMIT_COUNT=$(git rev-list --count "$oldrev..$newrev" 2>/dev/null)
# 채널별 알림 분기 플래그
TO_PM=0; TO_DEV=0; TO_PLAN=0; TO_ALL=0
while IFS= read -r FILE; do
case "$FILE" in
공유/소통/PM→개발팀/*|공유/소통/개발팀→PM/*)
TO_PM=1; TO_DEV=1 ;;
공유/소통/PM→기획팀/*|공유/소통/기획팀→PM/*)
TO_PM=1; TO_PLAN=1 ;;
공유/소통/기획팀→개발팀/*)
TO_DEV=1 ;;
공유/소통/개발팀→기획팀/*)
TO_PLAN=1 ;;
공유/조직공지/*|공유/공통_업무_규칙.md)
TO_ALL=1 ;;
esac
done <<< "$CHANGED"
# 알림 발송
MSG_ESC=$(json_escape "$COMMIT_MSG")
DESC="**${MSG_ESC}**\\n\\n커밋: \`${SHORT_SHA}\` (${COMMIT_COUNT}건) by ${AUTHOR}"
[ $TO_PM -eq 1 ] && send_discord "$PM_WEBHOOK_URL" "📬 PM 수신 채널 변경" "$DESC" 3447003
[ $TO_DEV -eq 1 ] && send_discord "$DEV_WEBHOOK_URL" "📬 개발팀 수신 채널 변경" "$DESC" 5763719
[ $TO_PLAN -eq 1 ]&& send_discord "$PLAN_WEBHOOK_URL" "📬 기획팀 수신 채널 변경" "$DESC" 15105570
[ $TO_ALL -eq 1 ] && send_discord "$ALL_WEBHOOK_URL" "📜 코어룰/조직공지 변경" "$DESC" 15548997
done
exit 0