-
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
Merged
Merged
[TEST] Ci Cd 테스트 #18
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
43f487e
[TEST] Ci Cd 테스트
oxdjww 78aacbb
[TEST] Ci Cd 테스트
oxdjww 1ea639d
[TEST] Ci Cd 테스트
oxdjww ac81bd7
Merge branch 'main' into test/deploy
oxdjww 7d2db9c
[TEST] Ci Cd 테스트
oxdjww f503b2b
Merge branch 'main' into test/deploy
oxdjww 9748ee1
Merge branch 'main' into test/deploy
oxdjww b946ced
[TEST] Ci Cd 테스트
oxdjww 864e217
Merge branch 'main' into test/deploy
oxdjww fbc67c6
[TEST] Ci Cd 테스트
oxdjww dd8c1fa
[TEST] Ci Cd 테스트
oxdjww f7226f3
Merge branch 'main' into test/deploy
oxdjww File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,13 +1,52 @@ | ||
| #!/usr/bin/env bash | ||
| set -euo pipefail | ||
|
|
||
| # 1) 환경변수 로드 | ||
| echo "🔧 Deploying with image: $BACKEND_IMAGE" | ||
| # ————————————————————————————————— | ||
| # 0) 필수 환경변수 | ||
| : "${BACKEND_IMAGE:?Need to set BACKEND_IMAGE (e.g. <ECR_URI>:<TAG>)}" | ||
| : "${AWS_DEFAULT_REGION:?Need to set AWS_DEFAULT_REGION}" | ||
|
|
||
| # 2) ECS 서비스 업데이트 | ||
| # ECS 리소스 이름 | ||
| ECS_CLUSTER="focussu-backend" | ||
| ECS_SERVICE="focussu-backend-prod-service" | ||
| # ————————————————————————————————— | ||
|
|
||
| echo "🔧 Deploying image → $BACKEND_IMAGE" | ||
|
|
||
| # 1) 현재 서비스에 연결된 Task Definition ARN 조회 | ||
| CURRENT_TD_ARN=$(aws ecs describe-services \ | ||
| --cluster "$ECS_CLUSTER" \ | ||
| --services "$ECS_SERVICE" \ | ||
| --query 'services[0].taskDefinition' \ | ||
| --output text) | ||
| echo "ℹ️ Current task definition ARN: $CURRENT_TD_ARN" | ||
|
|
||
| # 2) Task Definition 상세 가져오기 | ||
| TD_JSON=$(aws ecs describe-task-definition \ | ||
| --task-definition "$CURRENT_TD_ARN" \ | ||
| --output json \ | ||
| --query 'taskDefinition') | ||
|
|
||
| # 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"'"' | ||
| ) | ||
|
|
||
| # 4) 새 Task Definition 리비전 등록 | ||
| NEW_TD_ARN=$(aws ecs register-task-definition \ | ||
| --cli-input-json "$TD_REG_INPUT" \ | ||
| --query 'taskDefinition.taskDefinitionArn' \ | ||
| --output text) | ||
| echo "🆕 Registered new task definition ARN: $NEW_TD_ARN" | ||
|
|
||
| # 5) 서비스 업데이트 + 강제 재배포 | ||
| aws ecs update-service \ | ||
| --cluster focussu-backend \ | ||
| --service focussu-backend-prod-service \ | ||
| --cluster "$ECS_CLUSTER" \ | ||
| --service "$ECS_SERVICE" \ | ||
| --task-definition "$NEW_TD_ARN" \ | ||
| --force-new-deployment \ | ||
| --region "$AWS_DEFAULT_REGION" \ | ||
| --output json | ||
|
|
||
| echo "✅ Deployment triggered!" | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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옵션을 활용해 변수를 안전하게 전달하세요.