From 3bac30fc44bac82d3515f6276927f50bbcd3ae1a Mon Sep 17 00:00:00 2001 From: hong seokho Date: Tue, 30 Jul 2024 16:33:33 +0900 Subject: [PATCH] =?UTF-8?q?fix=20:=20ci/cd=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../animation-application-ci-cd-flow.yml | 107 ------------------ .../animation-application-prod-ci-cd-flow.yml | 10 +- 2 files changed, 2 insertions(+), 115 deletions(-) delete mode 100644 .github/workflows/animation-application-ci-cd-flow.yml diff --git a/.github/workflows/animation-application-ci-cd-flow.yml b/.github/workflows/animation-application-ci-cd-flow.yml deleted file mode 100644 index 5b16512dc..000000000 --- a/.github/workflows/animation-application-ci-cd-flow.yml +++ /dev/null @@ -1,107 +0,0 @@ -name: animation-application-ci/cd - -on: - push: - branches: - - develop_back_animation - - 'hotfix/[0-9a-zA-z]+-B-animation-#[0-9a-zA-z]+' - pull_request: - branches: - - develop_back_animation - -jobs: - deploy-animation: - name: animation application deploy - if: ${{ github.event_name == 'push' }} - runs-on: ubuntu-latest - - defaults: - run: - working-directory: ./backend/AnimatedDrawings - - permissions: - id-token: write - contents: read - - steps: - - name: Checkout - uses: actions/checkout@v4 - with: - submodules: true - token: ${{ secrets.CI_PAT }} - - - name: move yaml files - run: | - mkdir -p ./config/yaml - cp -r ../core/src/main/resources/config ./application/config/yaml - - - name: Configure AWS credentials - uses: aws-actions/configure-aws-credentials@v4 - with: - role-to-assume: ${{ secrets.AWS_ROLE_ARN }} - aws-region: ${{ secrets.AWS_REGION }} - - - name: Login to Amazon ECR - id: login-ecr - uses: aws-actions/amazon-ecr-login@v2 - - - name: Extract metadata (tags, labels) for Docker - id: meta - uses: docker/metadata-action@v5 - with: - images: | - ${{ steps.login-ecr.outputs.registry }}/${{ secrets.AWS_ECR_ANIMATED_DRAWINGS_NAME }} - tags: | - type=raw,value=latest - - - name: Build and push - uses: docker/build-push-action@v5 - with: - context: ./backend/AnimatedDrawings - push: true - tags: ${{ steps.meta.outputs.tags }} - provenance: false - - - name: Get Github action IP - id: ip - uses: haythem/public-ip@v1.3 - - - name: Add Github Actions IP to Security group - run: | - aws ec2 authorize-security-group-ingress --group-id ${{ secrets.AWS_EC2_ANIMATED_DRAWINGS_SG_ID }} --group-name ${{secrets.AWS_EC2_ANIMATED_DRAWINGS_SG_NAME}} --protocol tcp --port 22 --cidr ${{ steps.ip.outputs.ipv4 }}/32 - - - name: Connect ec2 and Run Docker Container - uses: appleboy/ssh-action@v0.1.6 - env: - AWS_ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }} - with: - host: ${{ secrets.SSH_ANIMATED_DRAWINGS_HOST }} - username: ${{ secrets.SSH_USERNAME }} - key: ${{ secrets.SSH_CORE_PRIVATE_KEY }} - port: ${{ secrets.SSH_PORT }} - script: | - docker ps -q --filter "name=animated_drawings" | xargs -r docker stop - docker ps -aq --filter "name=animated_drawings" | xargs -r docker rm - aws ecr get-login-password --region ${{ secrets.AWS_REGION }} | docker login --username ${{ secrets.AWS_DOCKER_USER }} --password-stdin ${{ secrets.AWS_USER_ID }}.dkr.ecr.${{ secrets.AWS_REGION }}.amazonaws.com - docker image prune -f - docker pull ${{ steps.meta.outputs.tags }} - docker run -d -p 5555:5555 -p 9001:9001 --name animated_drawings -e ENVIRONMENT='dev' ${{ steps.meta.outputs.tags }} - - - name: Remove Github Actions IP from security group - if: always() - run: | - aws ec2 revoke-security-group-ingress --group-id ${{ secrets.AWS_EC2_ANIMATED_DRAWINGS_SG_ID }} --group-name ${{secrets.AWS_EC2_ANIMATED_DRAWINGS_SG_NAME}} --protocol tcp --port 22 --cidr ${{ steps.ip.outputs.ipv4 }}/32 - - - uses: sarisia/actions-status-discord@v1 - if: success() - with: - webhook: ${{ secrets.DISCORD_WEBHOOK }} - status: ${{ job.status }} - content: "여러분 <@384742716933668867> <@1084774841460215839> <@545902166842408960> <@1081452554149449748>\n 배포 완료했습니다!!" - title: "애니메이션 서버 배포 완료 알림" - description: "백엔드 애니메이션 개발 브랜치에 깃허브 액션으로 배포 완료" - image: ${{ secrets.EMBED_IMAGE }} - color: 0x0000ff - url: "https://github.com/tukcomCD2024/DroidBlossom/actions" - username: GitHub Actions Bot - avatar_url: ${{ secrets.AVATAR_URL }} \ No newline at end of file diff --git a/.github/workflows/animation-application-prod-ci-cd-flow.yml b/.github/workflows/animation-application-prod-ci-cd-flow.yml index 7c967e97a..cb4e05e10 100644 --- a/.github/workflows/animation-application-prod-ci-cd-flow.yml +++ b/.github/workflows/animation-application-prod-ci-cd-flow.yml @@ -4,7 +4,6 @@ on: push: branches: - prod_back_animation - - build/cicd-prod-B-#580 - 'hotfix/[0-9a-zA-z]+-B-animation-#[0-9a-zA-z]+' pull_request: branches: @@ -31,11 +30,6 @@ jobs: submodules: true token: ${{ secrets.CI_PAT }} - - name: move yaml files - run: | - mkdir -p ./config/yaml - cp -r ../core/src/main/resources/config ./application/config/yaml - - name: Configure AWS credentials uses: aws-actions/configure-aws-credentials@v4 with: @@ -84,9 +78,9 @@ jobs: docker ps -q --filter "name=animated_drawings" | xargs -r docker stop docker ps -aq --filter "name=animated_drawings" | xargs -r docker rm aws ecr get-login-password --region ${{ secrets.AWS_REGION }} | docker login --username ${{ secrets.AWS_DOCKER_USER }} --password-stdin ${{ secrets.AWS_USER_ID }}.dkr.ecr.${{ secrets.AWS_REGION }}.amazonaws.com - docker image prune -f + docker image prune -f -a docker pull ${{ steps.meta.outputs.tags }} - docker run -d -p 5555:5555 -p 9001:9001 --name animated_drawings -v log_volume:/app/application/log -e ENVIRONMENT='dev' ${{ steps.meta.outputs.tags }} + docker run -d -p 5555:5555 -p 9001:9001 --name animated_drawings -v log_volume:/app/application/log -e ENVIRONMENT='container' ${{ steps.meta.outputs.tags }} - name: Remove Github Actions IP from security group if: always()