Conversation
- 헬스 체크 기능 추가 - 배포 실패 시, 알림 기능 추가
|
""" WalkthroughGitHub Actions 워크플로(dev, prod)에 수동 트리거(workflow_dispatch)와 배포 후 헬스 체크 및 실패 시 Discord 알림 기능이 추가되었습니다. dev, prod 환경 각각에 대해 health-check.sh 스크립트가 새로 도입되어 배포 정상 여부를 자동으로 확인합니다. Changes
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
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Assessment against linked issues
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 detailsConfiguration used: .coderabbit.yaml 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (2)
⏰ 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)
✨ Finishing Touches🧪 Generate unit tests
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed 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)
Other keywords and placeholders
Documentation and Community
|
Test Results118 files 118 suites 14s ⏱️ Results for commit c0a5579. ♻️ This comment has been updated with latest results. |
📝 Test Coverage Report
|
There was a problem hiding this comment.
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.sh와sh ~/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
📒 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)
There was a problem hiding this comment.
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
📒 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
추가 스크립트가 없으므로 해당 경로 설정은 의도대로 동작합니다.
| - name: Health Check | ||
| run: sh ~/app/scripts/health-check.sh |
There was a problem hiding this comment.
💡 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"
fiLength of output: 925
워크플로우 경로 불일치 확인 및 수정 필요
scripts/dev/health-check.sh파일이 존재하고 내용도 적절함을 확인했습니다.- 그러나
.github/workflows/Dev_CD.yml75–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.
| - 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.
coli-geonwoo
left a comment
There was a problem hiding this comment.
/noti
에러 픽스하면서 커찬이 만든 헬스체크 한번 슥 읽어보아서 approve 합니다.
이야기한 것처럼 retry interval 을 조금 올리는게 좋아보여요.
.github/workflows/Dev_CD.yml
Outdated
| path: ./scripts/dev/replace-new-version.sh | ||
| if-no-files-found: error | ||
|
|
||
| - name: Upload health check scripts |
There was a problem hiding this comment.
[의견]
이거 따로 분리하는게 나아보여서 각각 따로 업로드했는데 아마 커찬이 한것처럼 ./scripts/dev/*로 한번에 업로드해도 될 거에요. 이건 커찬 선호방식에 따라 개선해도 될듯!
🚩 연관 이슈
closed #210
🗣️ 리뷰 요구사항 (선택)
replace-new-version.sh은 아키펙트로 말아지는데,health-check.sh는 같은 폴더에 있는데 아키펙트로 안말아짐... 이거 해결 방법 아시는 분~Summary by CodeRabbit