Skip to content

Commit e3b6a3f

Browse files
authored
[Fix]:배포 오류 수정
[Fix]:배포 오류 수정
2 parents c88431d + 6856b5e commit e3b6a3f

File tree

1 file changed

+24
-9
lines changed

1 file changed

+24
-9
lines changed

.github/workflows/deploy.yml

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -120,27 +120,42 @@ jobs:
120120
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
121121
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
122122
aws-region: ${{ env.AWS_REGION }}
123+
124+
- name: Setup SSH key
125+
run: |
126+
echo "${{ secrets.EC2_SSH_KEY }}" > /tmp/ssh_key
127+
chmod 600 /tmp/ssh_key
123128
124129
- name: Deploy Application
125130
run: |
126-
# Trigger instance refresh to deploy new version
127-
aws autoscaling start-instance-refresh \
128-
--auto-scaling-group-name team12-asg-1 \
129-
--preferences '{"MinHealthyPercentage": 50}'
131+
echo "Deploying new Docker image to EC2..."
130132
131-
echo "Deployment initiated for team12-asg-1"
132-
echo "Instance refresh started. Waiting 5 minutes for deployment..."
133-
sleep 300
133+
# EC2에 SSH로 접속하여 Docker 이미지 업데이트
134+
ssh -i /tmp/ssh_key -o StrictHostKeyChecking=no [email protected] << 'EOF'
135+
cd /app
136+
137+
# ECR 로그인
138+
aws ecr get-login-password --region ap-northeast-2 | \
139+
docker login --username AWS --password-stdin 174170816230.dkr.ecr.ap-northeast-2.amazonaws.com
140+
141+
# 최신 이미지 pull 및 재시작
142+
docker-compose pull app
143+
docker-compose up -d
144+
145+
echo "Deployment completed"
146+
EOF
134147
135148
- name: Health Check
136149
run: |
137150
echo "Running health check on https://api.bid-market.shop"
138-
for i in {1..30}; do
151+
sleep 30 # 애플리케이션 시작 대기
152+
153+
for i in {1..20}; do
139154
if curl -f https://api.bid-market.shop/actuator/health; then
140155
echo "Health check passed!"
141156
exit 0
142157
fi
143-
echo "Waiting for application... ($i/30)"
158+
echo "Waiting for application... ($i/20)"
144159
sleep 10
145160
done
146161
echo "Health check failed!"

0 commit comments

Comments
 (0)