From 3a33ef5abc70376e95b058d2bdc1fd6093326a30 Mon Sep 17 00:00:00 2001 From: Yeongseo Na Date: Wed, 23 Oct 2024 22:07:02 +0900 Subject: [PATCH] =?UTF-8?q?[BE]=20=EB=AC=B4=EC=A4=91=EB=8B=A8=20=EB=B0=B0?= =?UTF-8?q?=ED=8F=AC=20=EC=A0=81=EC=9A=A9=20(#900)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * chore: 무중단 배포 cd를 기존 cd에 적용 - 불필요한 환경변수 제거 - dev: 자동 - prod: 수동, 하나씩만 cd가 일어나게 설정 * chore: 블루 그린이 병렬로 실행되도록 - 순차적으로 실행되는 롤링보다, 원래의 의도였던 블루그린에 가까운 방식이 되도록 한다. --- .github/workflows/backend-dev-cd.yml | 12 +-- .github/workflows/backend-prod-cd.yml | 16 ++-- .../zero-downtime-deploy-test-cd.yml | 82 ------------------- 3 files changed, 11 insertions(+), 99 deletions(-) delete mode 100644 .github/workflows/zero-downtime-deploy-test-cd.yml diff --git a/.github/workflows/backend-dev-cd.yml b/.github/workflows/backend-dev-cd.yml index 54e58aad0..d0d2c39b2 100644 --- a/.github/workflows/backend-dev-cd.yml +++ b/.github/workflows/backend-dev-cd.yml @@ -9,8 +9,6 @@ on: - 'backend/**' env: - ARTIFACT_NAME: review-me-dev - ARTIFACT_DIRECTORY: ./backend/build/libs APPLICATION_DIRECTORY: /home/ubuntu/review-me jobs: @@ -79,9 +77,11 @@ jobs: username: ${{ secrets.DOCKERHUB_ID }} password: ${{ secrets.DOCKERHUB_TOKEN }} - - name: Pull from DockerHub + - name: Deploy new version + env: + PROFILE_VAR: "dev" run: | - sudo docker-compose --env-file .env.dev down || true - sudo docker pull ${{ secrets.DOCKERHUB_ID }}/review-me-app:develop - sudo docker-compose --env-file .env.dev up -d + chmod +x ./deploy.sh + sudo -E ./deploy.sh + working-directory: ${{ env.APPLICATION_DIRECTORY }}/app diff --git a/.github/workflows/backend-prod-cd.yml b/.github/workflows/backend-prod-cd.yml index 3c79f4b85..c010d96e3 100644 --- a/.github/workflows/backend-prod-cd.yml +++ b/.github/workflows/backend-prod-cd.yml @@ -2,15 +2,8 @@ name: "[RELEASE] CD using Github self-hosted runner" on: workflow_dispatch: - push: - branches: - - release - paths: - - 'backend/**' env: - ARTIFACT_NAME: review-me-prod - ARTIFACT_DIRECTORY: ./backend/build/libs APPLICATION_DIRECTORY: /home/ubuntu/review-me jobs: @@ -82,9 +75,10 @@ jobs: username: ${{ secrets.DOCKERHUB_ID }} password: ${{ secrets.DOCKERHUB_TOKEN }} - - name: Pull from DockerHub + - name: Deploy new version + env: + PROFILE_VAR: "prod" run: | - sudo docker-compose --env-file .env.prod down || true - sudo docker pull ${{ secrets.DOCKERHUB_ID }}/review-me-app:release - sudo docker-compose --env-file .env.prod up -d + chmod +x ./deploy.sh + sudo -E ./deploy.sh working-directory: ${{ env.APPLICATION_DIRECTORY }}/app diff --git a/.github/workflows/zero-downtime-deploy-test-cd.yml b/.github/workflows/zero-downtime-deploy-test-cd.yml deleted file mode 100644 index ff91878ac..000000000 --- a/.github/workflows/zero-downtime-deploy-test-cd.yml +++ /dev/null @@ -1,82 +0,0 @@ -name: "[test] Zero Downtime Deploy Test CD" - -on: - workflow_dispatch: - -env: - APPLICATION_DIRECTORY: /home/ubuntu/review-me - -jobs: - build: - name: Build Dockerfile and push to DockerHub - runs-on: ubuntu-latest - - steps: - - name: Checkout to current repository - uses: actions/checkout@v4 - - - name: Setup JDK Corretto using cached gradle dependencies - uses: actions/setup-java@v4 - with: - distribution: 'corretto' - java-version: 17 - cache: 'gradle' - - - name: Setup Gradle - uses: gradle/actions/setup-gradle@v3 - with: - gradle-version: 8.8 - - - name: Build and test with gradle - run: | - cd ./backend - ./gradlew clean bootJar - - - name: Login to DockerHub - uses: docker/login-action@v3 - with: - username: ${{ secrets.DOCKERHUB_ID }} - password: ${{ secrets.DOCKERHUB_TOKEN }} - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v3 - - - name: Build and push - uses: docker/build-push-action@v6 - with: - context: ./backend - platforms: linux/amd64,linux/arm64 - push: true - tags: ${{ secrets.DOCKERHUB_ID }}/review-me-app:develop - - deploy: - name: Deploy via self-hosted runner - needs: build - runs-on: [self-hosted, dev] - - steps: - - name: Checkout to secret repository - uses: actions/checkout@v4 - with: - repository: ${{ secrets.PRIVATE_REPOSITORY_URL }} - token: ${{ secrets.PRIVATE_REPOSITORY_TOKEN }} - - - name: Move application-related files to local - run: | - mkdir -p ${{ env.APPLICATION_DIRECTORY }}/app - mv ./app/* ./app/.* ${{ env.APPLICATION_DIRECTORY }}/app - - - name: Login to DockerHub - uses: docker/login-action@v3 - with: - username: ${{ secrets.DOCKERHUB_ID }} - password: ${{ secrets.DOCKERHUB_TOKEN }} - - - name: Deploy new version # 변경 부분 - env: - PROFILE_VAR: "dev" - run: | - chmod +x ./deploy.sh - sudo -E ./deploy.sh - - working-directory: ${{ env.APPLICATION_DIRECTORY }}/app