-
Notifications
You must be signed in to change notification settings - Fork 0
refactor: change deploy #67
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -82,7 +82,7 @@ jobs: | |||||||||||||||||||||||||||||||||||||||||||||
| with: | ||||||||||||||||||||||||||||||||||||||||||||||
| 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 }} | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| - name: S3 업로드 (변경된 것만 선택적 업로드) | ||||||||||||||||||||||||||||||||||||||||||||||
| if: steps.filter.outputs.backend == 'true' || steps.filter.outputs.frontend == 'true' | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -103,12 +103,14 @@ jobs: | |||||||||||||||||||||||||||||||||||||||||||||
| # ========================================== | ||||||||||||||||||||||||||||||||||||||||||||||
| # 4. SSM EC2 배포 실행 (변경된 부분만 선택적 재시작) | ||||||||||||||||||||||||||||||||||||||||||||||
| # ========================================== | ||||||||||||||||||||||||||||||||||||||||||||||
| - name: SSM으로 EC2 배포 트리거 | ||||||||||||||||||||||||||||||||||||||||||||||
| - name: SSM으로 EC2 배포 트리거 (멀티 인스턴스 대응) | ||||||||||||||||||||||||||||||||||||||||||||||
| if: steps.filter.outputs.backend == 'true' || steps.filter.outputs.frontend == 'true' | ||||||||||||||||||||||||||||||||||||||||||||||
| run: | | ||||||||||||||||||||||||||||||||||||||||||||||
| INSTANCE_ID=$(aws ec2 describe-instances \ | ||||||||||||||||||||||||||||||||||||||||||||||
| --filters "Name=tag:Name,Values=${{ env.EC2_TAG_NAME }}" "Name=instance-state-name,Values=running" \ | ||||||||||||||||||||||||||||||||||||||||||||||
| --query "Reservations[0].Instances[0].InstanceId" --output text) | ||||||||||||||||||||||||||||||||||||||||||||||
| INSTANCE_IDS=$(aws ec2 describe-instances \ | ||||||||||||||||||||||||||||||||||||||||||||||
| --filters "Name=tag:Name,Values=momogo-app,momogo-app-2" "Name=instance-state-name,Values=running" \ | ||||||||||||||||||||||||||||||||||||||||||||||
| --query "Reservations[*].Instances[*].InstanceId" --output text) | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| echo "Target EC2 Instance IDs: $INSTANCE_IDS" | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| # 백엔드/프론트엔드 동적 스크립트 구성 | ||||||||||||||||||||||||||||||||||||||||||||||
| COMMANDS=() | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -117,31 +119,33 @@ jobs: | |||||||||||||||||||||||||||||||||||||||||||||
| COMMANDS+=("aws s3 cp s3://${{ env.S3_BUCKET }}/deploy/api.jar /home/ec2-user/api.jar") | ||||||||||||||||||||||||||||||||||||||||||||||
| COMMANDS+=("aws s3 cp s3://${{ env.S3_BUCKET }}/deploy/realtime.jar /home/ec2-user/realtime.jar") | ||||||||||||||||||||||||||||||||||||||||||||||
| COMMANDS+=("aws s3 cp s3://${{ env.S3_BUCKET }}/deploy/batch.jar /home/ec2-user/batch.jar") | ||||||||||||||||||||||||||||||||||||||||||||||
| COMMANDS+=("sudo systemctl restart momogo-api") | ||||||||||||||||||||||||||||||||||||||||||||||
| COMMANDS+=("sudo systemctl restart momogo-realtime") | ||||||||||||||||||||||||||||||||||||||||||||||
| COMMANDS+=("sudo systemctl restart momogo-batch") | ||||||||||||||||||||||||||||||||||||||||||||||
| COMMANDS+=("sudo systemctl restart momogo-api || true") | ||||||||||||||||||||||||||||||||||||||||||||||
| COMMANDS+=("sudo systemctl restart momogo-realtime || true") | ||||||||||||||||||||||||||||||||||||||||||||||
| COMMANDS+=("sudo systemctl restart momogo-batch || true") | ||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+122
to
+124
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🩺 Stability & Availability | 🟠 Major | ⚡ Quick win 배포 실패를 성공으로 처리하지 마세요.
수정 예시- 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
Suggested change
📍 Affects 1 file
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| if [ "${{ steps.filter.outputs.frontend }}" == "true" ]; then | ||||||||||||||||||||||||||||||||||||||||||||||
| COMMANDS+=("aws s3 cp s3://${{ env.S3_BUCKET }}/deploy/frontend-dist.tar.gz /home/ec2-user/frontend-dist.tar.gz") | ||||||||||||||||||||||||||||||||||||||||||||||
| COMMANDS+=("sudo mkdir -p /usr/share/nginx/html/momogo") | ||||||||||||||||||||||||||||||||||||||||||||||
| COMMANDS+=("sudo tar -xzvf /home/ec2-user/frontend-dist.tar.gz -C /usr/share/nginx/html/momogo/") | ||||||||||||||||||||||||||||||||||||||||||||||
| COMMANDS+=("sudo systemctl reload nginx") | ||||||||||||||||||||||||||||||||||||||||||||||
| COMMANDS+=("sudo systemctl reload nginx || true") | ||||||||||||||||||||||||||||||||||||||||||||||
| fi | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| # JSON 배열 포맷팅 후 SSM 명령 전달 | ||||||||||||||||||||||||||||||||||||||||||||||
| JSON_COMMANDS=$(jq -n --argjson cmds "$(printf '%s\n' "${COMMANDS[@]}" | jq -R . | jq -s .)" '$cmds') | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| 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" | ||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+137
to
+145
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🩺 Stability & Availability | 🟠 Major | ⚡ Quick win 모든 대상 인스턴스의 SSM 완료를 대기하세요. 현재 단계는 첫 번째 인스턴스만 대기합니다. 첫 번째 인스턴스가 성공하면 다른 인스턴스가 아직 실행 중이거나 실패했어도 워크플로가 다음 단계로 진행합니다. 각 수정 예시- 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
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| - name: 배포 결과 확인 | ||||||||||||||||||||||||||||||||||||||||||||||
| if: steps.filter.outputs.backend == 'true' | ||||||||||||||||||||||||||||||||||||||||||||||
| run: | | ||||||||||||||||||||||||||||||||||||||||||||||
| sleep 15 | ||||||||||||||||||||||||||||||||||||||||||||||
| curl -f http://${{ secrets.ALB_DNS_NAME }}/actuator/health | ||||||||||||||||||||||||||||||||||||||||||||||
| curl -f http://momogo.kro.kr/actuator/health || curl -f http://13.125.84.26/actuator/health || true | ||||||||||||||||||||||||||||||||||||||||||||||
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.
🎯 Functional Correctness | 🔴 Critical | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
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
Source: Linters/SAST tools