refactor: change deploy - #67
Conversation
📝 WalkthroughWalkthrough프로덕션 배포 워크플로가 AWS 리전 참조를 변경하고, 두 태그의 실행 중인 EC2 인스턴스 전체에 SSM 명령을 전달하도록 수정되었습니다. 배포 상태 확인은 기본 도메인과 고정 IP 주소를 순서대로 사용합니다. Changes프로덕션 배포 워크플로
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 주소로 재시도
Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
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
📒 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 }} |
There was a problem hiding this comment.
🎯 Functional Correctness | 🔴 Critical | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
set -euo pipefail
actionlint .github/workflows/deploy-production.ymlRepository: 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
| COMMANDS+=("sudo systemctl restart momogo-api || true") | ||
| COMMANDS+=("sudo systemctl restart momogo-realtime || true") | ||
| COMMANDS+=("sudo systemctl restart momogo-batch || true") |
There was a problem hiding this comment.
🩺 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.
| 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.
| 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" |
There was a problem hiding this comment.
🩺 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.
| 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.
작업 내용
변경 사항
체크리스트
참고 사항
관련 이슈
Summary by CodeRabbit