diff --git a/.github/workflows/rankit-multiaz-cicd.yml b/.github/workflows/rankit-multiaz-cicd.yml index b430734..5cbe98d 100644 --- a/.github/workflows/rankit-multiaz-cicd.yml +++ b/.github/workflows/rankit-multiaz-cicd.yml @@ -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 @@ -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