Skip to content

Commit

Permalink
Update rankit-multiaz-cicd.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
Oodls authored Oct 24, 2024
1 parent fdd786f commit 40238f4
Showing 1 changed file with 8 additions and 17 deletions.
25 changes: 8 additions & 17 deletions .github/workflows/rankit-multiaz-cicd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -81,17 +81,12 @@ jobs:
aws ssm send-command \
--instance-ids "${{ secrets.EC2_A_ID }}" \
--document-name "AWS-RunShellScript" \
--parameters 'commands=[
"if [ $(docker ps -q -f \"ancestor=${{ secrets.DOCKER_USERNAME }}/rankitrun-be:latest\" -f \"status=running\") ]; then docker stop $(docker ps -q -f \"ancestor=${{ secrets.DOCKER_USERNAME }}/rankitrun-be:latest\"); fi",
"sleep 10",
"docker pull ${{ secrets.DOCKER_USERNAME }}/rankitrun-be:latest",
"cd /home/ec2-user/app", # docker-compose.yml 파일이 있는 경로로 이동
"docker-compose -f docker-compose.yml up -d"
]' \
--parameters '{"commands": [
"if [ $(docker ps -q -f \\"ancestor=${{ secrets.DOCKER_USERNAME }}/rankitrun-be:latest\\" -f \\"status=running\\") ]; then docker stop $(docker ps -q -f \\"ancestor=${{ secrets.DOCKER_USERNAME }}/rankitrun-be:latest\\"); fi && docker pull ${{ secrets.DOCKER_USERNAME }}/rankitrun-be:latest && cd /home/ec2-user && docker-compose -f docker-compose.yml up -d"
]}' \
--comment "Deploying application to EC2-A"
# 5. EC2-A에서 헬스체크 수행
- name: Perform health check on EC2-A
id: healthcheck-ec2-a
Expand Down Expand Up @@ -130,22 +125,18 @@ jobs:
--target-group-arn ${{ secrets.TARGET_GROUP_ARN }} \
--targets Id=${{ secrets.EC2_C_ID }}
# 8. EC2-C에 Docker 컨테이너 배포
# 8. EC2-C에 Docker 컨테이너 배포
- name: Deploy to EC2-C via SSM
run: |
aws ssm send-command \
--instance-ids "${{ secrets.EC2_C_ID }}" \
--document-name "AWS-RunShellScript" \
--parameters 'commands=[
"if [ $(docker ps -q -f \"ancestor=${{ secrets.DOCKER_USERNAME }}/rankitrun-be:latest\" -f \"status=running\") ]; then docker stop $(docker ps -q -f \"ancestor=${{ secrets.DOCKER_USERNAME }}/rankitrun-be:latest\"); fi",
"sleep 10",
"docker pull ${{ secrets.DOCKER_USERNAME }}/rankitrun-be:latest",
"cd /home/ec2-user/app", # docker-compose.yml 파일이 있는 경로로 이동
"chmod +x docker-compose.yml", # 실행 권한 부여
"docker-compose -f docker-compose.yml up -d"
]' \
--parameters '{"commands": [
"if [ $(docker ps -q -f \\"ancestor=${{ secrets.DOCKER_USERNAME }}/rankitrun-be:latest\\" -f \\"status=running\\") ]; then docker stop $(docker ps -q -f \\"ancestor=${{ secrets.DOCKER_USERNAME }}/rankitrun-be:latest\\"); fi && docker pull ${{ secrets.DOCKER_USERNAME }}/rankitrun-be:latest && cd /home/ec2-user && docker-compose -f docker-compose.yml up -d"
]}' \
--comment "Deploying application to EC2-C"
# 9. EC2-C에서 헬스체크 수행
- name: Perform health check on EC2-C
id: healthcheck-ec2-c
Expand Down

0 comments on commit 40238f4

Please sign in to comment.