-
Notifications
You must be signed in to change notification settings - Fork 0
[TEST] Ci Cd 테스트 #18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[TEST] Ci Cd 테스트 #18
Conversation
Walkthrough이 변경 사항은 배포 자동화 스크립트인 Changes
Poem
✨ Finishing Touches
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:
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
|
There was a problem hiding this 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 (1)
deploy/deploy-prod.sh (1)
9-11: ECS 클러스터 및 서비스 이름 하드코딩 검토
현재 스크립트 내ECS_CLUSTER와ECS_SERVICE를 고정값으로 설정하고 있습니다. 테스트나 다른 환경에서 재사용성을 높이려면 환경 변수나 스크립트 인수로 오버라이드할 수 있도록 개선을 고려해 보세요.
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
deploy/deploy-prod.sh(1 hunks)
🔇 Additional comments (7)
deploy/deploy-prod.sh (7)
4-7: 필수 환경 변수 검증: 파라미터 익스팬션 사용
BACKEND_IMAGE와AWS_DEFAULT_REGION이 미설정 시 스크립트가 즉시 종료되어 조기 실패를 보장합니다.
14-14: 배포 시작 로깅
echo "🔧 Deploying image → $BACKEND_IMAGE"로 배포 대상 이미지를 명확히 출력하는 것은 디버깅 및 모니터링에 유용합니다.
16-22: 현재 Task Definition ARN 조회 구현 적절
aws ecs describe-services와--query 'services[0].taskDefinition'조합으로 현재 서비스의 Task Definition ARN을 정확히 가져오고 있습니다. 오류 시set -e에 의해 스크립트가 중단됩니다.
24-28: Task Definition JSON 조회 로직 확인
aws ecs describe-task-definition --query 'taskDefinition'을 사용해 필요한 JSON만 가져오는 흐름이 효율적이며,AWS_DEFAULT_REGION환경변수로 region이 자동 설정되므로 별도 플래그 없이도 동작합니다.
36-41: 새 Task Definition 리비전 등록 로직 확인
aws ecs register-task-definition --cli-input-json로 JSON을 입력받아 새로운 리비전을 등록하고, ARN을 추출해 로그로 출력하는 흐름이 명확합니다.
43-49: 서비스 업데이트 명령 구성 적절
aws ecs update-service에--task-definition,--force-new-deployment,--region을 포함하여 강제 재배포를 수행하는 부분이 올바르게 구현되었습니다.
52-52: 최종 배포 완료 로깅
echo "✅ Deployment triggered!"로 스크립트 완료 시점을 명확히 알리는 로그를 추가한 것은 사용자 경험을 높입니다.
| # 3) register-task-definition 에 넘길 JSON로 정리 | ||
| TD_REG_INPUT=$(echo "$TD_JSON" | jq \ | ||
| 'del(.taskDefinitionArn, .revision, .status, .requiresAttributes, .compatibilities, .registeredAt, .registeredBy) | ||
| | .containerDefinitions[0].image = "'"$BACKEND_IMAGE"'"' | ||
| ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
jq 변수 인젝션 방식 개선 제안
현재 문자열 연결로 이미지를 삽입하고 있는데, 이미지 이름에 특수문자가 포함되면 JQ 쿼리가 깨질 수 있습니다. 아래처럼 --arg 옵션을 활용해 변수를 안전하게 전달하세요.
- TD_REG_INPUT=$(echo "$TD_JSON" | jq \
- 'del(.taskDefinitionArn, .revision, .status, .requiresAttributes, .compatibilities, .registeredAt, .registeredBy)
- | .containerDefinitions[0].image = "'"$BACKEND_IMAGE"'"'
- )
+ TD_REG_INPUT=$(echo "$TD_JSON" | jq --arg IMAGE "$BACKEND_IMAGE" \
+ 'del(.taskDefinitionArn, .revision, .status, .requiresAttributes, .compatibilities, .registeredAt, .registeredBy)
+ | .containerDefinitions[0].image = $IMAGE'
+ )
Summary by CodeRabbit