Skip to content

refactor: change deploy - #67

Merged
SungHuii merged 1 commit into
developfrom
chore/refactor-deploy
Aug 10, 2026
Merged

refactor: change deploy#67
SungHuii merged 1 commit into
developfrom
chore/refactor-deploy

Conversation

@SungHuii

@SungHuii SungHuii commented Aug 10, 2026

Copy link
Copy Markdown
Collaborator

작업 내용

  • 분산환경 전환 작업

변경 사항

체크리스트

  • 테스트 코드 작성 완료
  • 리뷰어 지정 완료

참고 사항

관련 이슈

Summary by CodeRabbit

  • 개선 사항
    • 여러 실행 환경에 배포 명령을 전달하도록 배포 절차를 개선했습니다.
    • 서비스 재시작 및 웹 서버 설정 재적용 과정에서 일시적인 오류가 발생해도 배포가 중단되지 않도록 안정성을 높였습니다.
    • 배포 후 기본 접속 주소와 보조 접속 경로를 순차적으로 확인해 서비스 상태 검증을 강화했습니다.

@coderabbitai

coderabbitai Bot commented Aug 10, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

프로덕션 배포 워크플로가 AWS 리전 참조를 변경하고, 두 태그의 실행 중인 EC2 인스턴스 전체에 SSM 명령을 전달하도록 수정되었습니다. 배포 상태 확인은 기본 도메인과 고정 IP 주소를 순서대로 사용합니다.

Changes

프로덕션 배포 워크플로

Layer / File(s) Summary
AWS 설정 및 EC2 배포 대상 조회
.github/workflows/deploy-production.yml
AWS 자격 증명 단계의 리전 표현이 ${{ .env.AWS_REGION }}으로 변경되었습니다. momogo-appmomogo-app-2 태그를 가진 실행 중인 EC2 인스턴스 전체를 조회합니다.
다중 인스턴스 SSM 배포
.github/workflows/deploy-production.yml
SSM 명령을 조회된 모든 인스턴스에 전달합니다. 서비스 재시작과 Nginx 재로드 실패는 무시합니다. 명령 완료는 첫 번째 인스턴스를 기준으로 대기합니다.
배포 상태 확인
.github/workflows/deploy-production.yml
momogo.kro.kr을 먼저 호출합니다. 호출이 실패하면 고정 IP 주소로 재시도합니다.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant GitHubActions
  participant EC2Instances
  participant SSM
  participant HealthCheck
  GitHubActions->>EC2Instances: 실행 중인 태그 기반 인스턴스 조회
  GitHubActions->>SSM: 전체 인스턴스에 배포 명령 전달
  SSM->>EC2Instances: 서비스 재시작 및 Nginx 재로드 실행
  GitHubActions->>SSM: 첫 번째 인스턴스의 명령 완료 대기
  GitHubActions->>HealthCheck: momogo.kro.kr 호출
  HealthCheck-->>GitHubActions: 실패 시 고정 IP 주소로 재시도
Loading

Possibly related PRs

Suggested reviewers: idktomorrow, jaejo

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed 제목은 배포 설정 변경을 나타내며 변경 사항과 관련되지만, 분산 환경 전환이라는 핵심 내용은 구체적으로 설명하지 않습니다.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch chore/refactor-deploy

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.

@jaejo jaejo left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

고생하셨습니다.

@idktomorrow idktomorrow left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

수정하시느라 고생하셨습니다! ❤️

@SungHuii
SungHuii merged commit 3730755 into develop Aug 10, 2026
1 of 2 checks passed

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In @.github/workflows/deploy-production.yml:
- Line 85: Update the aws-region configuration to reference the workflow
environment variable with the valid env.AWS_REGION expression, removing the
leading dot from the current expression.
- Around line 137-145: Update the SSM wait logic after `COMMAND_ID` is created
to wait for `command-executed` on every instance in `INSTANCE_IDS`, not only
`FIRST_INSTANCE`. Iterate over all target instance IDs and preserve the existing
command ID and AWS CLI waiter usage for each one.
- Around line 122-124: Remove error suppression from the deployment commands so
failures propagate: update .github/workflows/deploy-production.yml lines 122-124
for the momogo-api, momogo-realtime, and momogo-batch restarts, and line 131 for
Nginx reload. At line 151, retain fallback from the first status URL to the
second, but make the step fail when both URL checks fail.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 40ba55f1-45ab-4fe9-ae00-f62b24d483ef

📥 Commits

Reviewing files that changed from the base of the PR and between 3035d5f and 10ce4df.

📒 Files selected for processing (1)
  • .github/workflows/deploy-production.yml

aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ env.AWS_REGION }}
aws-region: ${{ .env.AWS_REGION }}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🔴 Critical | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail
actionlint .github/workflows/deploy-production.yml

Repository: MoMoGo-QuizPlatform/MoMoGo

Length of output: 480


.env.AWS_REGION 표현식을 env.AWS_REGION으로 수정하세요.

${{ .env.AWS_REGION }}는 유효하지 않은 GitHub Actions 표현식입니다. env는 워크플로 파일 최상위 env 블록에서 정의된 변수에 접근하는 컨텍스트이므로, 이 표기로 파스 오류가 사라집니다.

🧰 Tools
🪛 actionlint (1.7.12)

[error] 85-85: unexpected token "." while parsing variable access, function call, null, bool, int, float or string. expecting "IDENT", "(", "INTEGER", "FLOAT", "STRING"

(expression)

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.github/workflows/deploy-production.yml at line 85, Update the aws-region
configuration to reference the workflow environment variable with the valid
env.AWS_REGION expression, removing the leading dot from the current expression.

Source: Linters/SAST tools

Comment on lines +122 to +124
COMMANDS+=("sudo systemctl restart momogo-api || true")
COMMANDS+=("sudo systemctl restart momogo-realtime || true")
COMMANDS+=("sudo systemctl restart momogo-batch || true")

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🩺 Stability & Availability | 🟠 Major | ⚡ Quick win

배포 실패를 성공으로 처리하지 마세요.

|| true는 서비스 재시작, Nginx 재로드, 그리고 두 상태 확인 URL의 실패를 모두 성공으로 처리합니다. 배포 대상이 이전 버전으로 남아도 워크플로가 성공할 수 있습니다.

  • .github/workflows/deploy-production.yml#L122-L124: momogo-api, momogo-realtime, momogo-batch 재시작 실패를 전파하세요.
  • .github/workflows/deploy-production.yml#L131-L131: Nginx 재로드 실패를 전파하세요.
  • .github/workflows/deploy-production.yml#L151-L151: 첫 번째 URL 실패 시 두 번째 URL만 시도하고, 둘 다 실패하면 단계를 실패시키세요.
수정 예시
-            COMMANDS+=("sudo systemctl restart momogo-api || true")
-            COMMANDS+=("sudo systemctl restart momogo-realtime || true")
-            COMMANDS+=("sudo systemctl restart momogo-batch || true")
+            COMMANDS+=("sudo systemctl restart momogo-api")
+            COMMANDS+=("sudo systemctl restart momogo-realtime")
+            COMMANDS+=("sudo systemctl restart momogo-batch")
...
-            COMMANDS+=("sudo systemctl reload nginx || true")
+            COMMANDS+=("sudo systemctl reload nginx")
...
-          curl -f http://momogo.kro.kr/actuator/health || curl -f http://13.125.84.26/actuator/health || true
+          curl -f http://momogo.kro.kr/actuator/health || curl -f http://13.125.84.26/actuator/health
📝 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
COMMANDS+=("sudo systemctl restart momogo-api || true")
COMMANDS+=("sudo systemctl restart momogo-realtime || true")
COMMANDS+=("sudo systemctl restart momogo-batch || true")
COMMANDS+=("sudo systemctl restart momogo-api")
COMMANDS+=("sudo systemctl restart momogo-realtime")
COMMANDS+=("sudo systemctl restart momogo-batch")
📍 Affects 1 file
  • .github/workflows/deploy-production.yml#L122-L124 (this comment)
  • .github/workflows/deploy-production.yml#L131-L131
  • .github/workflows/deploy-production.yml#L151-L151
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.github/workflows/deploy-production.yml around lines 122 - 124, Remove error
suppression from the deployment commands so failures propagate: update
.github/workflows/deploy-production.yml lines 122-124 for the momogo-api,
momogo-realtime, and momogo-batch restarts, and line 131 for Nginx reload. At
line 151, retain fallback from the first status URL to the second, but make the
step fail when both URL checks fail.

Comment on lines +137 to +145
FIRST_INSTANCE=$(echo $INSTANCE_IDS | awk '{print $1}')

COMMAND_ID=$(aws ssm send-command \
--instance-ids "$INSTANCE_ID" \
--instance-ids $INSTANCE_IDS \
--document-name "AWS-RunShellScript" \
--parameters "{\"commands\": $JSON_COMMANDS}" \
--query "Command.CommandId" --output text)

aws ssm wait command-executed --command-id "$COMMAND_ID" --instance-id "$INSTANCE_ID"
aws ssm wait command-executed --command-id "$COMMAND_ID" --instance-id "$FIRST_INSTANCE"

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🩺 Stability & Availability | 🟠 Major | ⚡ Quick win

모든 대상 인스턴스의 SSM 완료를 대기하세요.

현재 단계는 첫 번째 인스턴스만 대기합니다. 첫 번째 인스턴스가 성공하면 다른 인스턴스가 아직 실행 중이거나 실패했어도 워크플로가 다음 단계로 진행합니다.

INSTANCE_IDS 대상의 command-executed 상태를 대기하세요.

수정 예시
-          FIRST_INSTANCE=$(echo $INSTANCE_IDS | awk '{print $1}')
-
           COMMAND_ID=$(aws ssm send-command \
             --instance-ids $INSTANCE_IDS \
             --document-name "AWS-RunShellScript" \
             --parameters "{\"commands\": $JSON_COMMANDS}" \
             --query "Command.CommandId" --output text)
 
-          aws ssm wait command-executed --command-id "$COMMAND_ID" --instance-id "$FIRST_INSTANCE"
+          for INSTANCE_ID in $INSTANCE_IDS; do
+            aws ssm wait command-executed \
+              --command-id "$COMMAND_ID" \
+              --instance-id "$INSTANCE_ID"
+          done
📝 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
FIRST_INSTANCE=$(echo $INSTANCE_IDS | awk '{print $1}')
COMMAND_ID=$(aws ssm send-command \
--instance-ids "$INSTANCE_ID" \
--instance-ids $INSTANCE_IDS \
--document-name "AWS-RunShellScript" \
--parameters "{\"commands\": $JSON_COMMANDS}" \
--query "Command.CommandId" --output text)
aws ssm wait command-executed --command-id "$COMMAND_ID" --instance-id "$INSTANCE_ID"
aws ssm wait command-executed --command-id "$COMMAND_ID" --instance-id "$FIRST_INSTANCE"
COMMAND_ID=$(aws ssm send-command \
--instance-ids $INSTANCE_IDS \
--document-name "AWS-RunShellScript" \
--parameters "{\"commands\": $JSON_COMMANDS}" \
--query "Command.CommandId" --output text)
for INSTANCE_ID in $INSTANCE_IDS; do
aws ssm wait command-executed \
--command-id "$COMMAND_ID" \
--instance-id "$INSTANCE_ID"
done
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.github/workflows/deploy-production.yml around lines 137 - 145, Update the
SSM wait logic after `COMMAND_ID` is created to wait for `command-executed` on
every instance in `INSTANCE_IDS`, not only `FIRST_INSTANCE`. Iterate over all
target instance IDs and preserve the existing command ID and AWS CLI waiter
usage for each one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants