Skip to content

Commit

Permalink
feature: 개발 환경 CICD 구축
Browse files Browse the repository at this point in the history
  • Loading branch information
junseublim committed Aug 3, 2024
1 parent 5186e35 commit a718115
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 9 deletions.
22 changes: 13 additions & 9 deletions .github/workflows/cicd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
5 changes: 5 additions & 0 deletions src/components/GoogleAnalytics.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
import Script from 'next/script'
import { isDevMode } from '@/lib/utils/env'

const GoogleAnalytics = () => {
if (isDevMode) {
return null
}

return (
<>
<Script
Expand Down
1 change: 1 addition & 0 deletions src/lib/utils/env.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const isDevMode = process.env.NODE_ENV === 'development'

0 comments on commit a718115

Please sign in to comment.