Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 14 additions & 4 deletions .github/workflows/Dev_CD.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
name: dev-cd

on:
workflow_dispatch:
push:
branches:
- "develop"
Expand All @@ -10,10 +11,8 @@ jobs:
runs-on: ubuntu-latest

steps:
- name: Checkout Develop Branch
- name: Checkout Branch
uses: actions/checkout@v4
with:
ref: "develop"

- name: Setting dev-secret.yml
run: |
Expand Down Expand Up @@ -66,7 +65,18 @@ jobs:
uses: actions/download-artifact@v4
with:
name: deploy-scripts
path: ~/app/scripts
path: ~/app/scripts/

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

- name: Health Check
run: sh ~/app/scripts/health-check.sh
Comment on lines +73 to +74
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.


- 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 }}
16 changes: 13 additions & 3 deletions .github/workflows/Prod_CD.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
name: prod-cd

on:
workflow_dispatch:
push:
branches:
- "main"
Expand All @@ -12,8 +13,6 @@ jobs:
steps:
- name: Checkout Develop Branch
uses: actions/checkout@v4
with:
ref: "main"

- name: Setting prod-secret.yml
run: |
Expand Down Expand Up @@ -66,7 +65,18 @@ jobs:
uses: actions/download-artifact@v4
with:
name: deploy-scripts
path: ~/app/scripts
path: ~/app/scripts/

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

- name: 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\":\":warning: :warning: [PROD] 배포 실패! :warning: :warning: \n링크: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}\"}" \
${{ secrets.DISCORD_WEB_HOOK }}
31 changes: 31 additions & 0 deletions scripts/dev/health-check.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/bin/bash

# 최대 반복 횟수
MAX_RETRIES=60

# 성공 상태 코드와 요청 URL
SUCCESS_STATUS=200
HEALTH_CHECK_URL="http://localhost:8083/monitoring/health"

# 반복 시작
i=1
while [ "$i" -le "$MAX_RETRIES" ]; do
# HTTP 요청 보내기
RESPONSE_STATUS=$(curl -s -o /dev/null -w "%{http_code}" "$HEALTH_CHECK_URL")
echo "[TRY $i] StatusCode : $RESPONSE_STATUS "
# 상태 코드 확인
if [ "$RESPONSE_STATUS" -eq "$SUCCESS_STATUS" ]; then
echo "Success: Received $SUCCESS_STATUS status code on attempt $i."
exit 0
fi

# 2초 대기
sleep 2

# 반복 변수 증가
i=$((i + 1))
done

# 실패 메시지
echo "Failure: Did not receive $SUCCESS_STATUS status code within $MAX_RETRIES attempts."
exit 1
31 changes: 31 additions & 0 deletions scripts/prod/health-check.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/bin/bash

# 최대 반복 횟수
MAX_RETRIES=60

# 성공 상태 코드와 요청 URL
SUCCESS_STATUS=200
HEALTH_CHECK_URL="http://localhost:8083/monitoring/health"

# 반복 시작
i=1
while [ "$i" -le "$MAX_RETRIES" ]; do
# HTTP 요청 보내기
RESPONSE_STATUS=$(curl -s -o /dev/null -w "%{http_code}" "$HEALTH_CHECK_URL")
echo "[TRY $i] StatusCode : $RESPONSE_STATUS "
# 상태 코드 확인
if [ "$RESPONSE_STATUS" -eq "$SUCCESS_STATUS" ]; then
echo "Success: Received $SUCCESS_STATUS status code on attempt $i."
exit 0
fi

# 2초 대기
sleep 2

# 반복 변수 증가
i=$((i + 1))
done

# 실패 메시지
echo "Failure: Did not receive $SUCCESS_STATUS status code within $MAX_RETRIES attempts."
exit 1
Loading