From 8727de07895a4458ef137457352502fd5c257faf Mon Sep 17 00:00:00 2001 From: donghwan Date: Mon, 2 Jun 2025 12:53:48 +0900 Subject: [PATCH] =?UTF-8?q?refactor=20:=20yaml=20=ED=8C=8C=EC=9D=BC=20?= =?UTF-8?q?=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/frontend-cicd.yml | 94 +++++++++++++++-------------- .github/workflows/main.yml | 57 ----------------- 2 files changed, 49 insertions(+), 102 deletions(-) delete mode 100644 .github/workflows/main.yml diff --git a/.github/workflows/frontend-cicd.yml b/.github/workflows/frontend-cicd.yml index 66a6c86..db0114f 100644 --- a/.github/workflows/frontend-cicd.yml +++ b/.github/workflows/frontend-cicd.yml @@ -4,54 +4,58 @@ on: push: branches: [ main ] paths: - - '**' - - '.github/workflows/frontend-cicd.yml' + - '**' + - '.github/workflows/frontend-cicd.yml' jobs: build-and-deploy-frontend: runs-on: ubuntu-latest steps: - - name: Checkout Repository - uses: actions/checkout@v3 - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v2 - - - name: Log in to Docker Hub - uses: docker/login-action@v2 - with: - username: ${{ secrets.DOCKERHUB_USERNAME }} - password: ${{ secrets.DOCKERHUB_TOKEN }} - - - name: Build and Push Docker Image to DockerHub - run: | - docker buildx build \ - --platform linux/amd64 \ - -t ${{ secrets.DOCKERHUB_USERNAME }}/frontend-service:latest \ - --push . - - - name: Configure AWS Credentials - uses: aws-actions/configure-aws-credentials@v2 - with: - aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} - aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} - aws-region: ap-northeast-2 - - - name: Update kubeconfig for EKS - run: | - aws eks update-kubeconfig \ - --region ap-northeast-2 \ - --name nsmm-eks - - - name: Replace Image Tag in deployment.yaml - run: | - sed -i "s|image: .*frontend-service.*|image: ${{ secrets.DOCKERHUB_USERNAME }}/frontend-service:latest|g" deployment.yaml - - - name: Deploy to EKS - run: | - kubectl apply -f deployment.yaml - - - name: Verify Deployment - run: | - kubectl rollout status deployment/frontend-service + - name: Checkout Repository + uses: actions/checkout@v3 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + + - name: Log in to Docker Hub + uses: docker/login-action@v2 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - name: Build and Push Docker Image to DockerHub + run: | + docker buildx build \ + --platform linux/amd64 \ + -t ${{ secrets.DOCKERHUB_USERNAME }}/frontend-service:latest \ + --push . + + - name: Configure AWS Credentials + uses: aws-actions/configure-aws-credentials@v2 + with: + aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} + aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + aws-region: ap-northeast-2 + + - name: Update kubeconfig for EKS + run: | + aws eks update-kubeconfig \ + --region ap-northeast-2 \ + --name nsmm-eks + + - name: Replace Image Tag in deployment.yaml + run: | + sed -i "s|image: .*frontend-service.*|image: ${{ secrets.DOCKERHUB_USERNAME }}/frontend-service:latest|g" deployment.yaml + + - name: Deploy to EKS + run: | + kubectl apply -f deployment.yaml + + - name: Force Restart Deployment + run: | + kubectl rollout restart deployment/frontend-service + + - name: Verify Deployment + run: | + kubectl rollout status deployment/frontend-service diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml deleted file mode 100644 index 1020d57..0000000 --- a/.github/workflows/main.yml +++ /dev/null @@ -1,57 +0,0 @@ -name: Build and Deploy Frontend to EKS - -on: - push: - branches: [ main ] - paths: - - 'frontend/**' - - '.github/workflows/frontend-cicd.yml' - -jobs: - build-and-deploy-frontend: - runs-on: ubuntu-latest - - steps: - - name: Checkout Repository - uses: actions/checkout@v3 - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v2 - - - name: Log in to Docker Hub - uses: docker/login-action@v2 - with: - username: ${{ secrets.DOCKERHUB_USERNAME }} - password: ${{ secrets.DOCKERHUB_TOKEN }} - - - name: Build and Push Docker Image to DockerHub - run: | - docker buildx build \ - --platform linux/amd64 \ - -t ${{ secrets.DOCKERHUB_USERNAME }}/frontend-service:latest \ - --push ./frontend - - - name: Configure AWS Credentials - uses: aws-actions/configure-aws-credentials@v2 - with: - aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} - aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} - aws-region: ap-northeast-2 - - - name: Update kubeconfig for EKS - run: | - aws eks update-kubeconfig \ - --region ap-northeast-2 \ - --name nsmm-eks - - - name: Replace Image Tag in frontend/deployment.yaml - run: | - sed -i "s|image: .*frontend-service.*|image: ${{ secrets.DOCKERHUB_USERNAME }}/frontend-service:latest|g" frontend/deployment.yaml - - - name: Deploy frontend to EKS - run: | - kubectl apply -f frontend/deployment.yaml - - - name: Verify Deployment - run: | - kubectl rollout status deployment/frontend-service