From 593a4f24ba4eb8d15b5199597771e42bd0c4fc2a Mon Sep 17 00:00:00 2001 From: MyeongJi_Shin <89967069+tlsaudwl@users.noreply.github.com> Date: Wed, 3 Jul 2024 13:08:40 +0900 Subject: [PATCH] Create deploy.yml MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 프론트엔드 cicd deploy.yml --- .github/workflows/deploy.yml | 52 ++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 .github/workflows/deploy.yml diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml new file mode 100644 index 0000000..a0a7300 --- /dev/null +++ b/.github/workflows/deploy.yml @@ -0,0 +1,52 @@ +name: Frontend CI/CD + +on: + push: + branches: + - dev + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Set up Node.js + uses: actions/setup-node@v4 + with: + node-version: '18' + + - name: Install dependencies + run: yarn install + + - name: Build the project + run: yarn build + + - name: Log in to Docker Hub + run: echo ${{ secrets.DOCKER_PASSWORD }} | docker login -u ${{ secrets.DOCKER_USERNAME }} --password-stdin + + - name: Build Docker image + run: docker build -t ${{ secrets.DOCKER_USERNAME }}/hanalink-react:latest . + + - name: Push Docker image + run: docker push ${{ secrets.DOCKER_USERNAME }}/hanalink-react:latest + + - name: Set up kubectl + run: | + mkdir -p $HOME/.kube + echo "${{ secrets.KUBECONFIG }}" | base64 --decode > $HOME/.kube/config + env: + KUBECONFIG: $HOME/.kube/config + + - name: Delete old pods + run: kubectl delete pods -l app=hanalink-react-app + env: + KUBECONFIG: $HOME/.kube/config + + - name: Deploy to Kubernetes + run: | + kubectl set image deployment/hanalink-react-app hanalink-react-app=${{ secrets.DOCKER_USERNAME }}/hanalink-react:latest + env: + KUBECONFIG: $HOME/.kube/config