diff --git a/.github/workflows/backend-prod-ci-cd.yml b/.github/workflows/backend-prod-ci-cd.yml index 1298c15c..59c3a490 100644 --- a/.github/workflows/backend-prod-ci-cd.yml +++ b/.github/workflows/backend-prod-ci-cd.yml @@ -8,11 +8,11 @@ on: - ".github/workflows/backend-prod-ci-cd.yml" - "Dockerfile" pull_request: - branches: [ "main" ] - paths: - - "backend/**" - - ".github/workflows/backend-prod-ci-cd.yml" - - "Dockerfile" + branches: [ "main" ] + paths: + - "backend/**" + - ".github/workflows/backend-prod-ci-cd.yml" + - "Dockerfile" jobs: @@ -45,9 +45,9 @@ jobs: run: | echo "${{ secrets.APPLICATION_PROPERTIES_PROD }}" > src/main/resources/application.properties mkdir -p src/main/resources/fcm - echo '${{ secrets.FCM_SECRET_KEY }}' > src/main/resources/fcm/chongdaemarket-fcm-key.json + echo "${{ secrets.FCM_SECRET_KEY }}" > src/main/resources/fcm/chongdaemarket-fcm-key.json mkdir -p src/test/resources/fcm - echo '${{ secrets.FCM_SECRET_KEY }}' > src/test/resources/fcm/chongdaemarket-fcm-key.json + echo "${{ secrets.FCM_SECRET_KEY }}" > src/test/resources/fcm/chongdaemarket-fcm-key.json working-directory: ./backend - name: Build with Gradle Wrapper @@ -58,23 +58,23 @@ jobs: run: | docker login -u ${{ secrets.BE_DOCKERHUB_USERNAME }} -p ${{ secrets.BE_DOCKERHUB_PASSWORD }} docker build -t ${{ secrets.BE_DOCKER_IMAGE_NAME_PROD }} . - docker tag ${{ secrets.BE_DOCKER_IMAGE_NAME_PROD }} ${{ secrets.BE_DOCKERHUB_USERNAME }}/${{ secrets.BE_DOCKER_IMAGE_NAME_PROD }}:${GITHUB_SHA::7} - docker push ${{ secrets.BE_DOCKERHUB_USERNAME }}/${{ secrets.BE_DOCKER_IMAGE_NAME_PROD }}:${GITHUB_SHA::7} + docker tag ${{ secrets.BE_DOCKER_IMAGE_NAME_PROD }} ${{ secrets.BE_DOCKERHUB_USERNAME }}/${{ secrets.BE_DOCKER_IMAGE_NAME_PROD }}:${{ github.sha::7 }} + docker push ${{ secrets.BE_DOCKERHUB_USERNAME }}/${{ secrets.BE_DOCKER_IMAGE_NAME_PROD }}:${{ github.sha::7 }} deploy-new-container: needs: build-and-test strategy: matrix: runner: [prod-a, prod-b] - runs-on: [ self-hosted, ${{ matrix.runner }} ] - steps: - - name: Checkout repository - uses: actions/checkout@v4 + runs-on: [ self-hosted, ${{ matrix.runner }} ] + steps: + - name: Checkout repository + uses: actions/checkout@v4 - - name: Deploy new container on ${{ matrix.runner }} - run: | - bash launch_next_container.sh ${GITHUB_SHA::7} prod ${{ secrets.BE_DOCKERHUB_USERNAME }} ${{ secrets.BE_DOCKER_IMAGE_NAME_PROD }} - working-directory: backend/deploy + - name: Deploy new container on ${{ matrix.runner }} + run: | + bash launch_next_container.sh ${GITHUB_SHA::7} prod ${{ secrets.BE_DOCKERHUB_USERNAME }} ${{ secrets.BE_DOCKER_IMAGE_NAME_PROD }} + working-directory: backend/deploy switch-new-container: needs: deploy-new-container