Skip to content

ci: Discord 알림 GitHub Action 추가#10

Merged
chanwoo7 merged 2 commits intomainfrom
ci/discord-notify
Mar 15, 2026
Merged

ci: Discord 알림 GitHub Action 추가#10
chanwoo7 merged 2 commits intomainfrom
ci/discord-notify

Conversation

@chanwoo7
Copy link
Member

@chanwoo7 chanwoo7 commented Mar 15, 2026

PR Summary

GitHub Actions 워크플로와 실행 스크립트를 추가하여 특정 GitHub 이벤트 발생 시 Discord Webhook으로 포맷된 Embed 알림을 전송합니다.
이 PR에는 이벤트 판별 로직, Embed 생성 유틸, 실행 스크립트 및 해당 로직을 검증하는 유닛 테스트가 포함되어 있습니다.

  • .github/workflows/discord-notify.yml 워크플로 추가 — PR 머지(closed/merged), 브랜치 생성, push, 이슈 오픈 이벤트를 처리
  • .github/scripts/discord-notify.mjs 실행 스크립트 추가 — 이벤트 로드, 판별, Embed 생성 후 Discord Webhook 호출
  • .github/scripts/discord-notify-lib.mjs 라이브러리 추가 — 이벤트 타입 해석 및 다양한 Embed 빌더(프리젠테이션 로직)
  • .github/scripts/__tests__/discord-notify-lib.spec.mjs 단위 테스트 추가 — 빌더 및 이벤트 판별 동작 검증
  • 워크플로는 DISCORD_WEBHOOK_URL 시크릿과 Node.js v24 환경을 사용

Changes

4 files changed

File Changes
.github/scripts/__tests__/discord-notify-lib.spec.mjs Discord 알림 라이브러리에 대한 유닛 테스트를 추가합니다. resolveEventType, 각종 build*Embed 함수 및 buildWebhookBody의 동작(색상, 필드, URL, 커밋 요약 등)을 다양한 케이스로 검증합니다.
.github/scripts/discord-notify-lib.mjs 이벤트 판별 함수 resolveEventType와 Discord Embed 생성 유틸을 추가합니다. 주요 빌더로는 buildPrMergedEmbed, buildBranchCreatedEmbed, buildBranchPushEmbed, buildIssueOpenedEmbed가 포함되며, repoLink, authorLink, truncate 같은 내부 유틸을 제공합니다.
.github/scripts/discord-notify.mjs GitHub Actions에서 실행되는 메인 실행 스크립트를 추가합니다. 환경변수 검사(DISCORD_WEBHOOK_URL, GITHUB_EVENT_NAME, GITHUB_EVENT_PATH, GITHUB_REPOSITORY), 이벤트 로드 및 판별, Embed 생성 후 Discord Webhook으로 POST 호출을 수행하며 실패 시 에러를 로깅하고 비정상 종료합니다.
.github/workflows/discord-notify.yml 새 워크플로 Discord Notify를 추가합니다. 트리거: pull_request(closed), create, push, issues(opened). .github/scripts만 sparse-checkout 하여 워크플로에서 스크립트를 체크아웃하고 actions/setup-node@v4로 Node.js(설정: node-version: 24) 환경을 구성한 뒤 .github/scripts/discord-notify.mjs를 실행합니다. 실행 시 DISCORD_WEBHOOK_URL 시크릿을 사용합니다.

Impact

  • 특정 GitHub 이벤트가 발생하면 Discord로 실시간 알림이 전송됩니다 (PR 머지, 브랜치 생성, push, 이슈 오픈).
  • 워크플로 실행을 위해 DISCORD_WEBHOOK_URL 시크릿 설정이 필요합니다.
  • 워크플로에서 Node.js v24 환경을 사용합니다 (actions/setup-node@v4).
  • 애플리케이션 런타임 코드는 변경되지 않으며 CI/인프라 구성 변경에 한정됩니다.

Checklist

  • DISCORD_WEBHOOK_URL가 repository Secrets에 설정되어 있는지 확인하세요.
  • 워크플로 트리거가 의도한 이벤트에서만 실행되는지 확인하세요 (PR closed + merged, create(ref_type=branch), push, issues opened).
  • 로컬/테스트 환경에서 샘플 이벤트 페이로드로 node .github/scripts/discord-notify.mjs를 실행해 webhook 호출이 정상 동작하는지 검증하세요.
  • node 실행 환경이 v24인지(또는 호환되는지) 확인하세요 (actions/setup-node@v4 설정 검토).
  • 테스트 파일(.github/scripts/__tests__/discord-notify-lib.spec.mjs)이 CI에서 통과하는지 확인하세요.
  • Webhook 실패 시 에러 메시지(HTTP 상태코드 및 응답 본문)가 적절히 로깅되는지 확인하세요.
  • 전송되는 메시에 민감한 정보(예: 내부 URL, 토큰 등)가 포함되지 않는지 검토하세요.

Dependencies

  • GitHub Action uses actions/checkout@v4 and actions/setup-node@v4
  • 워크플로는 node-version: 24를 요구

Summary by CodeRabbit

릴리스 노트

  • 새로운 기능

    • Discord 웹훅을 통한 저장소 이벤트 알림 시스템 추가 (PR 병합, 브랜치 생성/푸시, 이슈 오픈)
  • 테스트

    • 알림 시스템의 포괄적인 테스트 스위트 추가 (이벤트 유형 해석, 임베드 생성, 페이로드 구성 등)
  • 자동화

    • GitHub Actions 워크플로우 추가로 해당 저장소 이벤트 발생 시 자동으로 Discord 알림 전송

@coderabbitai
Copy link

coderabbitai bot commented Mar 15, 2026

Caution

Review failed

Pull request was closed or merged during review

📝 Walkthrough

Walkthrough

Discord 알림 시스템을 GitHub Actions에 추가합니다. 새로운 라이브러리는 GitHub 이벤트를 Discord 임베드로 변환하고, 스크립트는 웹훅 URL로 알림을 전송합니다. 워크플로우는 PR, push, issue 이벤트를 트리거하며, 포괄적인 테스트 스위트가 모든 기능을 검증합니다.

Changes

Cohort / File(s) Summary
Discord Notification Library
.github/scripts/discord-notify-lib.mjs
New module exporting event type resolver, embed builders for PR merged/branch created/branch push/issue opened events, webhook body builder, and utility functions for formatting links and truncating strings. Handles payload extraction with safe fallbacks.
Discord Notification Workflow & Script
.github/workflows/discord-notify.yml, .github/scripts/discord-notify.mjs
New workflow triggered on PR closed, PR created, push, and issues opened. Script retrieves environment variables, loads GitHub event payload, resolves event type, builds embed, and sends POST request to Discord webhook with error handling and logging.
Test Suite
.github/scripts/__tests__/discord-notify-lib.spec.mjs
Comprehensive test file (230 lines) validating event resolution logic, all embed builders, webhook body construction, and edge cases including commit truncation, missing labels, and multilingual text.

Sequence Diagram(s)

sequenceDiagram
    participant GHA as GitHub Actions
    participant Script as discord-notify.mjs
    participant Lib as discord-notify-lib.mjs
    participant Discord as Discord Webhook
    
    GHA->>Script: Trigger with event context
    activate Script
    Script->>Script: Load env vars & GitHub event payload
    Script->>Lib: resolveEventType(eventName, payload)
    activate Lib
    Lib-->>Script: Internal event type
    deactivate Lib
    
    alt Event is notifiable
        Script->>Lib: buildEmbed(eventType, payload, meta)
        activate Lib
        Lib->>Lib: Call event-specific builder
        Lib-->>Script: Discord Embed object
        deactivate Lib
        
        Script->>Lib: buildWebhookBody(embed)
        activate Lib
        Lib-->>Script: Webhook payload
        deactivate Lib
        
        Script->>Discord: POST webhook payload
        activate Discord
        Discord-->>Script: 200 OK
        deactivate Discord
        Script->>Script: Log success
    else Event not notifiable
        Script->>Script: Skip notification
    end
    deactivate Script
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

🚥 Pre-merge checks | ✅ 2
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed PR 제목이 변경 내용을 정확하게 설명합니다. Discord 알림 기능을 위한 GitHub Action 추가라는 명확한 의도가 드러나 있으며, 제공된 요구사항(변경 내용을 간결하게 설명)을 충족합니다.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch ci/discord-notify
📝 Coding Plan
  • Generate coding plan for human review comments

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions github-actions bot added ⚙️ Setting 개발환경 세팅 🌏 Deploy 배포 관련 labels Mar 15, 2026
@github-actions github-actions bot changed the title Ci/discord notify ci: Discord 알림 GitHub Action 추가 Mar 15, 2026
@chanwoo7 chanwoo7 merged commit 91d8520 into main Mar 15, 2026
2 of 3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🌏 Deploy 배포 관련 ⚙️ Setting 개발환경 세팅

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant