Skip to content

Repository files navigation

🤖 Release Note Bot

AI-powered release note generator from git diffs

PR이 merge될 때 코드 변경 사항을 AI가 분석하여, 새롭게 개발된 기능·변경 사항을 비개발자도 이해할 수 있는 문서로 정리해 노션에 자동으로 전달합니다.

NestJS TypeScript Gemini Claude OpenAI Notion


✨ 기능

  • 코드 기반 분석 — PR의 git diff를 읽어 변경 내용을 파악
  • AI 요약 — AI가 기술적 변경을 비개발자 언어로 변환 (Gemini, Claude, OpenAI 등 교체 가능)
  • 노션 자동 기입 — 변경 전/후 구조로 노션 페이지에 자동 작성
  • 중복 방지 — 같은 PR 재실행 시 기존 페이지를 덮어씀
  • 유연한 트리거 — GitHub Actions, n8n, curl 등 어디서든 호출 가능

🔄 동작 흐름

PR merge (또는 수동 트리거)
    ↓
POST /api/v1/pr-analysis/trigger
    ↓
GitHub API → PR diff 수집 (최대 5000줄)
    ↓
AI → 변경 내용 분석 (Gemini / Claude / OpenAI)
    ↓
Notion API → 릴리즈 노트 페이지 생성/업데이트

📋 노션 출력 예시

Notion Example

🚀 시작하기

1. 환경 변수 설정

pnpm env:init   # 샘플 파일 생성
pnpm env:setup  # 대화형으로 값 입력

또는 apps/api/env/.env.local 직접 생성:

GITHUB_TOKEN=ghp_xxxxxxxxxxxxxxxxxxxx          # GitHub PR diff 조회용
GOOGLE_GENERATIVE_AI_API_KEY=AIzaSy...         # Gemini API 키
NOTION_TOKEN=ntn_xxxxxxxxxxxxxxxxxxxx          # Notion Integration 토큰
NOTION_PR_ANALYSIS_DB_ID=xxxxxxxxxxxxxxxx      # 릴리즈 노트 DB ID
PR_ANALYSIS_WEBHOOK_TOKEN=any-string-you-want  # API 무단 호출 방지용. 아무 값이나 설정하고 호출 시 동일한 값을 전달하면 됩니다.

2. 노션 설정

  1. 릴리즈 노트용 Notion Database 생성 (빈 DB도 OK — 프로퍼티 자동 생성됨)
  2. Notion Integration 생성 → 해당 DB에 연결 (DB 우상단 ...Connections)
  3. Integration Token을 NOTION_TOKEN에 설정

3. 실행

pnpm install
pnpm start:debug

📡 API

POST /api/v1/pr-analysis/trigger

Headers

Authorization: Bearer {PR_ANALYSIS_WEBHOOK_TOKEN}
Content-Type: application/json

Body

{
  "repo": "owner/repo",
  "prNumber": "123",
  "prTitle": "feat: 선택적 제목 (없으면 자동 생성)"
}

Response

{
  "result": "SUCCESS",
  "data": { "pageId": "notion-page-id" }
}

⚙️ 연동 방법

GitHub Actions

- name: Trigger Release Note
  run: |
    curl -s -X POST ${{ vars.RELEASE_NOTE_API_URL }}/api/v1/pr-analysis/trigger \
      -H "Authorization: Bearer ${{ secrets.PR_ANALYSIS_WEBHOOK_TOKEN }}" \
      -H "Content-Type: application/json" \
      -d '{"repo": "${{ github.repository }}", "prNumber": "${{ github.event.pull_request.number }}"}'

n8n

HTTP Request 노드:

  • Method: POST
  • URL: {API_URL}/api/v1/pr-analysis/trigger
  • Headers: Authorization: Bearer {token}
  • Body: { "repo": "owner/repo", "prNumber": "123" }

curl

curl -s -X POST http://localhost:8000/api/v1/pr-analysis/trigger \
  -H "Authorization: Bearer your-secret-token" \
  -H "Content-Type: application/json" \
  -d '{"repo": "owner/repo", "prNumber": "123"}'

🤖 AI 모델 교체

apps/api/src/domain/pr-analysis/PrCodeAnalyzer.ts에서 모델을 교체할 수 있어요.

Claude로 교체 시:

pnpm add @ai-sdk/anthropic
import { anthropic } from '@ai-sdk/anthropic';
model: anthropic('claude-sonnet-4-5')  // env: ANTHROPIC_API_KEY

OpenAI로 교체 시:

pnpm add @ai-sdk/openai
import { openai } from '@ai-sdk/openai';
model: openai('gpt-4o')  // env: OPENAI_API_KEY

기본값(Gemini)은 @ai-sdk/google이 이미 설치되어 있어요. Vercel AI SDK 지원 모델이면 모두 교체 가능합니다.

🛠 기술 스택

Runtime Node.js 22
Framework NestJS 11
Language TypeScript
AI Gemini / Claude / OpenAI (교체 가능)
Package Manager pnpm

📁 프로젝트 구조

apps/api/src/
├── api/v1/pr-analysis/       # Controller + DTO
├── application/pr-analysis/  # Pipeline 조율
├── common/                   # 공유 유틸
│   ├── env.ts                # 환경변수 검증 (zod)
│   └── notionRichText.ts     # 노션 rich text 빌더
├── domain/pr-analysis/       # 핵심 로직
│   ├── PrDiffFetcher.ts      # GitHub API
│   ├── PrCodeAnalyzer.ts     # Gemini AI
│   ├── PrNotionWriter.ts     # Notion API
│   └── CodeAnalysisSchema.ts # AI 응답 스키마
└── module/pr-analysis/       # NestJS DI 설정

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages