Skip to content

[CHORE] 정상 배포 확인을 위한 헬스 체크 기능 구현#211

Merged
leegwichan merged 14 commits intodevelopfrom
chore/#210
Jul 31, 2025
Merged

[CHORE] 정상 배포 확인을 위한 헬스 체크 기능 구현#211
leegwichan merged 14 commits intodevelopfrom
chore/#210

Conversation

@leegwichan
Copy link
Member

@leegwichan leegwichan commented Jul 30, 2025

🚩 연관 이슈

closed #210

🗣️ 리뷰 요구사항 (선택)

  • 이거 아키펙트로 스크립트 같이 말아서 올리는데... replace-new-version.sh은 아키펙트로 말아지는데, health-check.sh는 같은 폴더에 있는데 아키펙트로 안말아짐... 이거 해결 방법 아시는 분~

Summary by CodeRabbit

  • 새로운 기능
    • 배포 후 자동으로 서비스 상태를 점검하는 헬스 체크 기능이 추가되었습니다.
    • 배포 실패 시 Discord로 자동 알림이 전송됩니다.
    • 배포 워크플로우를 수동으로 실행할 수 있는 기능이 추가되었습니다.

@coderabbitai
Copy link

coderabbitai bot commented Jul 30, 2025

"""

Walkthrough

GitHub Actions 워크플로(dev, prod)에 수동 트리거(workflow_dispatch)와 배포 후 헬스 체크 및 실패 시 Discord 알림 기능이 추가되었습니다. dev, prod 환경 각각에 대해 health-check.sh 스크립트가 새로 도입되어 배포 정상 여부를 자동으로 확인합니다.

Changes

Cohort / File(s) Change Summary
GitHub Actions 워크플로 업데이트
.github/workflows/Dev_CD.yml, .github/workflows/Prod_CD.yml
workflow_dispatch(수동 트리거) 추가, 배포 후 health-check.sh 실행, 실패 시 Discord 알림 단계 추가
헬스 체크 스크립트 추가
scripts/dev/health-check.sh, scripts/prod/health-check.sh
HTTP 200 응답을 최대 60회까지 2초 간격으로 확인하는 health-check.sh 신규 도입

Sequence Diagram(s)

sequenceDiagram
    participant GitHubActions
    participant DeployServer
    participant HealthCheckScript
    participant DiscordWebhook

    GitHubActions->>DeployServer: 애플리케이션 배포
    GitHubActions->>HealthCheckScript: health-check.sh 실행
    HealthCheckScript->>DeployServer: http://localhost:8083/monitoring/health 요청 (최대 60회)
    alt 정상(200 응답)
        HealthCheckScript-->>GitHubActions: 성공(0 반환)
    else 실패(200 미응답)
        HealthCheckScript-->>GitHubActions: 실패(1 반환)
        GitHubActions->>DiscordWebhook: 실패 알림 전송
    end
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Assessment against linked issues

Objective Addressed Explanation
정상 배포 체크를 위한 헬스 체크 기능 구현 (#210)

Assessment against linked issues: Out-of-scope changes

(해당 변경사항은 모두 #210 이슈의 목적과 직접적으로 연관되어 있으므로, 범위를 벗어난 변경사항이 없습니다.)
"""

Note

⚡️ Unit Test Generation is now available in beta!

Learn more here, or try it out under "Finishing Touches" below.


📜 Recent review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 5f6d276 and c0a5579.

📒 Files selected for processing (2)
  • .github/workflows/Dev_CD.yml (3 hunks)
  • .github/workflows/Prod_CD.yml (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • .github/workflows/Prod_CD.yml
  • .github/workflows/Dev_CD.yml
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: build
  • GitHub Check: build-and-push
✨ Finishing Touches
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch chore/#210

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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@github-actions
Copy link

github-actions bot commented Jul 30, 2025

Test Results

118 files  118 suites   14s ⏱️
275 tests 275 ✅ 0 💤 0 ❌
287 runs  287 ✅ 0 💤 0 ❌

Results for commit c0a5579.

♻️ This comment has been updated with latest results.

@github-actions
Copy link

github-actions bot commented Jul 30, 2025

📝 Test Coverage Report

Overall Project 88.13% 🍏

There is no coverage information present for the Files changed

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🔭 Outside diff range comments (2)
.github/workflows/Prod_CD.yml (1)

48-54: 아티팩트 경로 업로드 방식으로 인한 실행 경로 불일치

path: ./scripts/prod/로 업로드하면 아티팩트 내부에 scripts/prod/… 경로가 그대로 보존됩니다.
다운로드 시 ~/app/scripts 하위에 다시 scripts/prod/… 가 생기므로,
아래 sudo sh ~/app/scripts/replace-new-version.shsh ~/app/scripts/health-check.sh는 파일을 찾지 못해 실패합니다.
(제보하신 “health-check.sh가 패키징되지 않는다” 문제가 이 지점에서 발생)

수정 예시:

-      - name: Download deploy scripts
-        uses: actions/download-artifact@v4
-        with:
-          name: deploy-scripts
-          path: ~/app/scripts
+      - name: Download deploy scripts
+        uses: actions/download-artifact@v4
+        with:
+          name: deploy-scripts
+          path: ~/app
...
-      - name: Replace application to latest
-        run: sudo sh ~/app/scripts/replace-new-version.sh
+      - name: Replace application to latest
+        run: sudo sh ~/app/scripts/prod/replace-new-version.sh
...
-      - name: Health Check
-        run: sh ~/app/scripts/health-check.sh
+      - name: Health Check
+        run: sh ~/app/scripts/prod/health-check.sh

또는 업로드 시 path: ./scripts/prod/* 로 평탄화(flatten)해도 됩니다.

.github/workflows/Dev_CD.yml (1)

48-54: DEV 워크플로우도 아티팩트 경로 오류 동일

prod와 동일한 방식으로 중첩 경로 문제로 인해 replace-new-version.sh / health-check.sh가 실행되지 않습니다.
Prod_CD.yml 코멘트와 같은 방식으로 경로를 정정해주세요.

♻️ Duplicate comments (1)
scripts/dev/health-check.sh (1)

1-31: 운영 스크립트와 동일 코드 중복

같은 개선 사항이 DEV에도 적용되어야 하며, 두 스크립트를 하나로 통합하면 DRY 원칙을 충족할 수 있습니다.

🧹 Nitpick comments (5)
scripts/prod/health-check.sh (3)

1-9: 스크립트 강인성 부족 – set -euo pipefail 추가 권장

예상치 못한 오류(예: 변수 오타, curl 실패 코드 6/7 등) 발생 시 스크립트가 그대로 진행됩니다.
초기에 Bash 옵션을 켜 두면 즉시 실패로 종료되어 GitHub Actions 단계가 올바르게 실패 상태를 리턴합니다.

 #!/bin/bash
+set -euo pipefail

6-9: 하드코딩된 URL‧포트 → 인자/환경변수로 주입

운영·스테이징 포트가 바뀌면 스크립트 수정이 필요합니다.
다음과 같이 기본값을 두고, 필요 시 HEALTH_CHECK_URL 환경변수로 오버라이드하도록 개선하면 재사용성이 높아집니다.

-HEALTH_CHECK_URL="http://localhost:8083/monitoring/health"
+HEALTH_CHECK_URL="${HEALTH_CHECK_URL:-http://localhost:8083/monitoring/health}"

10-31: DEV 스크립트와 100% 중복 – 공통 스크립트로 통합 고려

scripts/dev/health-check.sh와 본문 내용이 완전히 동일합니다.
health-check.sh 하나만 두고 환경변수로 동작을 분기하면 유지보수 비용을 절감할 수 있습니다.

.github/workflows/Prod_CD.yml (1)

78-84: Discord 알림 단계에서 실패 이모지 하드코딩 – 환경·브랜치별 메시지 구분 권장

운영·개발 모두 :x: 이모지만 사용하고 있어 로그 탐색 시 혼동될 수 있습니다.
ENV=PROD 같은 컨텍스트 변수를 사용해 색상/이모지를 다르게 표현하면 가독성이 높아집니다.

.github/workflows/Dev_CD.yml (1)

78-84: 개발 실패 알림 메시지 차별화 제안

운영과 개발 모두 동일 포맷의 알림으로 슬랙/디스코드 채널이 혼잡해질 수 있습니다.
:x: 대신 :warning: 등으로 레벨을 구분하거나, 메시지에 [DEV] 접두사 추가를 고려해보세요.

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between ca1c4c1 and 90a1b95.

📒 Files selected for processing (4)
  • .github/workflows/Dev_CD.yml (2 hunks)
  • .github/workflows/Prod_CD.yml (2 hunks)
  • scripts/dev/health-check.sh (1 hunks)
  • scripts/prod/health-check.sh (1 hunks)

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (2)
.github/workflows/Dev_CD.yml (2)

78-84: Discord 알림 기능 승인 및 개선 제안

배포 실패 시 Discord 알림을 보내는 기능이 잘 구현되었습니다. failure() 조건을 사용하여 이전 단계가 실패했을 때만 알림을 보내는 것이 적절합니다.

보안 강화를 위해 Discord 웹훅 URL을 직접 노출하지 않고 curl 명령어에서 에러 처리를 추가하는 것을 고려해보세요:

      - name: Send Discord Alert on Failure
        if: failure()
        run: |
-          curl -H "Content-Type: application/json" \
-               -X POST \
-               -d "{\"content\":\":x: [DEV] 배포 실패! 확인이 필요합니다.\n링크: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}\"}" \
-               ${{ secrets.DISCORD_WEB_HOOK }}
+          curl -H "Content-Type: application/json" \
+               -X POST \
+               -d "{\"content\":\":x: [DEV] 배포 실패! 확인이 필요합니다.\n링크: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}\"}" \
+               "${{ secrets.DISCORD_WEB_HOOK }}" \
+               --fail --silent --show-error

74-84: 워크플로 단계 순서 검토

현재 구조에서 헬스 체크가 실패하면 Discord 알림이 전송되는데, 헬스 체크 실패와 일반적인 배포 실패를 구분하여 더 구체적인 알림 메시지를 제공하는 것을 고려해보세요.

각 단계별로 구체적인 실패 메시지를 제공하도록 개선할 수 있습니다:

      - name: Replace application to latest
+        id: replace-app
        run: sudo sh ~/app/scripts/replace-new-version.sh

      - name: Health Check
+        id: health-check
        run: sh ~/app/scripts/health-check.sh

-      - name: Send Discord Alert on Failure
-        if: failure()
-        run: |
-          curl -H "Content-Type: application/json" \
-               -X POST \
-               -d "{\"content\":\":x: [DEV] 배포 실패! 확인이 필요합니다.\n링크: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}\"}" \
-               ${{ secrets.DISCORD_WEB_HOOK }}
+      - name: Send Discord Alert on App Replace Failure
+        if: steps.replace-app.outcome == 'failure'
+        run: |
+          curl -H "Content-Type: application/json" \
+               -X POST \
+               -d "{\"content\":\":x: [DEV] 애플리케이션 교체 실패! 확인이 필요합니다.\n링크: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}\"}" \
+               "${{ secrets.DISCORD_WEB_HOOK }}"
+
+      - name: Send Discord Alert on Health Check Failure
+        if: steps.health-check.outcome == 'failure'
+        run: |
+          curl -H "Content-Type: application/json" \
+               -X POST \
+               -d "{\"content\":\":x: [DEV] 헬스 체크 실패! 서비스 상태를 확인해주세요.\n링크: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}\"}" \
+               "${{ secrets.DISCORD_WEB_HOOK }}"
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 90a1b95 and 808a90a.

📒 Files selected for processing (2)
  • .github/workflows/Dev_CD.yml (3 hunks)
  • .github/workflows/Prod_CD.yml (3 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • .github/workflows/Prod_CD.yml
🔇 Additional comments (2)
.github/workflows/Dev_CD.yml (2)

4-4: 수동 트리거 기능 추가 승인

개발 환경 배포에 대한 수동 트리거 기능이 적절히 추가되었습니다. 이는 필요시 수동으로 배포를 실행할 수 있어 유용합니다.


52-52: 아티팩트 경로 포함 확인

./scripts/dev/* 패턴이 scripts/dev 디렉토리의 모든 스크립트 파일을 포함함을 확인했습니다.
현재 디렉토리 내 파일 목록:

  • scripts/dev/health-check.sh
  • scripts/dev/replace-new-version.sh

추가 스크립트가 없으므로 해당 경로 설정은 의도대로 동작합니다.

Comment on lines +75 to +76
- name: Health Check
run: sh ~/app/scripts/health-check.sh
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Verification agent

🧩 Analysis chain

헬스 체크 단계 구현 승인

배포 후 헬스 체크를 수행하는 단계가 적절히 추가되었습니다. 이는 배포가 정상적으로 완료되었는지 확인하는 중요한 기능입니다.

헬스 체크 스크립트가 실제로 존재하고 실행 가능한지 확인해주세요:


🏁 Script executed:

#!/bin/bash
# 헬스 체크 스크립트 존재 여부 및 권한 확인
if [ -f "scripts/dev/health-check.sh" ]; then
    echo "health-check.sh 파일 존재: YES"
    ls -la scripts/dev/health-check.sh
    echo "파일 내용:"
    cat scripts/dev/health-check.sh
else
    echo "health-check.sh 파일 존재: NO"
fi

Length of output: 925


워크플로우 경로 불일치 확인 및 수정 필요

  • scripts/dev/health-check.sh 파일이 존재하고 내용도 적절함을 확인했습니다.
  • 그러나 .github/workflows/Dev_CD.yml 75–76행에서는 ~/app/scripts/health-check.sh 경로를 사용하고 있어, 실행 환경에서 스크립트를 찾지 못할 가능성이 높습니다.
  • sh 스크립트경로 방식으로 호출할 경우 실행 권한(x) 플래그는 필요 없으므로 권한 문제는 없습니다.

수정 예시:

- name: Health Check
- run: sh ~/app/scripts/health-check.sh
+ name: Health Check
+ run: sh ./scripts/dev/health-check.sh

또는 스크립트를 app/scripts/health-check.sh로 이동 후 기존 경로를 유지해주세요.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
- name: Health Check
run: sh ~/app/scripts/health-check.sh
- name: Health Check
run: sh ./scripts/dev/health-check.sh
🤖 Prompt for AI Agents
In .github/workflows/Dev_CD.yml at lines 75-76, the script path used for the
health check is incorrect; it references ~/app/scripts/health-check.sh, but the
actual script is located at scripts/dev/health-check.sh. Update the run command
to use the correct relative path scripts/dev/health-check.sh to ensure the
script is found and executed properly during the workflow.

Copy link
Contributor

@coli-geonwoo coli-geonwoo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/noti

에러 픽스하면서 커찬이 만든 헬스체크 한번 슥 읽어보아서 approve 합니다.
이야기한 것처럼 retry interval 을 조금 올리는게 좋아보여요.

path: ./scripts/dev/replace-new-version.sh
if-no-files-found: error

- name: Upload health check scripts
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[의견]

이거 따로 분리하는게 나아보여서 각각 따로 업로드했는데 아마 커찬이 한것처럼 ./scripts/dev/*로 한번에 업로드해도 될 거에요. 이건 커찬 선호방식에 따라 개선해도 될듯!

Copy link
Contributor

@unifolio0 unifolio0 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@leegwichan leegwichan merged commit 77ad284 into develop Jul 31, 2025
5 of 6 checks passed
@leegwichan leegwichan deleted the chore/#210 branch July 31, 2025 02:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

chore 기타

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[CHORE] 정상 배포 확인을 위한 헬스 체크 기능 구현

3 participants