From 9970389ba6ff2a4e4cf6b0fdd6704aa444ea5f9e Mon Sep 17 00:00:00 2001 From: nayonsoso Date: Tue, 22 Oct 2024 20:00:10 +0900 Subject: [PATCH 1/2] =?UTF-8?q?chore:=20=EB=AC=B4=EC=A4=91=EB=8B=A8=20?= =?UTF-8?q?=EB=B0=B0=ED=8F=AC=20cd=EB=A5=BC=20=EA=B8=B0=EC=A1=B4=20cd?= =?UTF-8?q?=EC=97=90=20=EC=A0=81=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 불필요한 환경변수 제거 - dev: 자동 - prod: 수동, 하나씩만 cd가 일어나게 설정 --- .github/workflows/backend-dev-cd.yml | 12 +-- .github/workflows/backend-prod-cd.yml | 17 ++-- .../zero-downtime-deploy-test-cd.yml | 82 ------------------- 3 files changed, 12 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..7bbe00c53 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: @@ -60,6 +53,7 @@ jobs: name: Deploy via self-hosted runner needs: build strategy: + max-parallel: 1 matrix: runner: [prod-a, prod-b] runs-on: [ self-hosted, "${{ matrix.runner }}" ] @@ -82,9 +76,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 From 91870d9a7afe9a0b4004ea59b82bbd2ee2935326 Mon Sep 17 00:00:00 2001 From: nayonsoso Date: Tue, 22 Oct 2024 20:40:10 +0900 Subject: [PATCH 2/2] =?UTF-8?q?chore:=20=EB=B8=94=EB=A3=A8=20=EA=B7=B8?= =?UTF-8?q?=EB=A6=B0=EC=9D=B4=20=EB=B3=91=EB=A0=AC=EB=A1=9C=20=EC=8B=A4?= =?UTF-8?q?=ED=96=89=EB=90=98=EB=8F=84=EB=A1=9D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 순차적으로 실행되는 롤링보다, 원래의 의도였던 블루그린에 가까운 방식이 되도록 한다. --- .github/workflows/backend-prod-cd.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/backend-prod-cd.yml b/.github/workflows/backend-prod-cd.yml index 7bbe00c53..c010d96e3 100644 --- a/.github/workflows/backend-prod-cd.yml +++ b/.github/workflows/backend-prod-cd.yml @@ -53,7 +53,6 @@ jobs: name: Deploy via self-hosted runner needs: build strategy: - max-parallel: 1 matrix: runner: [prod-a, prod-b] runs-on: [ self-hosted, "${{ matrix.runner }}" ]