diff --git a/.github/workflows/cicd.yml b/.github/workflows/cicd.yml index d9ca78b..7a794f2 100644 --- a/.github/workflows/cicd.yml +++ b/.github/workflows/cicd.yml @@ -3,34 +3,38 @@ name: Deploy to AWS EC2 on: push: branches: - - main + - develop + release: + types: [published] jobs: build: - runs-on: self-hosted - + runs-on: ${{ github.event_name == 'release' && 'prod' || 'dev' }} + environment: + name: ${{ github.event_name == 'release' && 'production' || 'development' }} steps: - name: Checkout uses: actions/checkout@v4 - name: Set .ENV file run: | - echo "API_HOST=${{ secrets.API_HOST }}" >> .env + echo "API_HOST=${{ vars.API_HOST }}" >> .env + echo "NODE_ENV=${{ vars.NODE_ENV }}" >> .env echo "NEXT_PUBLIC_GA_ID=${{ secrets.PUBLIC_GA_ID }}" >> .env - name: Build docker image - run: docker build -t sonny2024/polabo-fe . + run: docker build -t ${{ vars.DOCKER_IMAGE }} . - name: Login to DockerHub run: echo "${{ secrets.DOCKERHUB_PASSWORD }}" | docker login -u "${{ secrets.DOCKERHUB_USERNAME }}" --password-stdin - name: Push to DockerHub - run: docker push sonny2024/polabo-fe:latest + run: docker push ${{ vars.DOCKER_IMAGE }} deploy: needs: build - runs-on: self-hosted + runs-on: ${{ github.event_name == 'release' && 'prod' || 'dev' }} steps: - name: Pull from DockerHub - run: docker pull sonny2024/polabo-fe:latest + run: docker pull ${{ vars.DOCKER_IMAGE }} - name: Delete existing container run: docker rm -f polabo-fe || true - name: Run container - run: docker run -d -p 3000:3000 --name polabo-fe sonny2024/polabo-fe:latest + run: docker run -d -p 3000:3000 --name polabo-fe ${{ vars.DOCKER_IMAGE }} diff --git a/src/components/GoogleAnalytics.tsx b/src/components/GoogleAnalytics.tsx index 430147e..7305fdf 100644 --- a/src/components/GoogleAnalytics.tsx +++ b/src/components/GoogleAnalytics.tsx @@ -1,6 +1,11 @@ import Script from 'next/script' +import { isDevMode } from '@/lib/utils/env' const GoogleAnalytics = () => { + if (isDevMode) { + return null + } + return ( <>