Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 7 additions & 34 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
name: 빌드 자동화

name: 빌드 자동화
on:
push:
branches:
- main
- feat/cicd
- dev

jobs:
build:
Expand All @@ -14,39 +13,13 @@ jobs:
- name: Checkout code
uses: actions/checkout@v2

- name: Set up Node.js (언어 환경)
- name: Set up Node.js (또는 다른 언어 환경)
uses: actions/setup-node@v2
with:
node-version: "20"

- name: Create .env.production file
run: |
echo "MODE=production" > .env.production
echo "VITE_GA_MEASUREMENT_ID=${{ secrets.VITE_GA_MEASUREMENT_ID }}" >> .env.production
node-version: '20'

- name: Install dependencies
run: npm ci
run: npm install

- name: Run build
env:
NODE_ENV: production
run: npm run build -- --mode production

- name: Docker build & push
run: |
docker login -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKER_PASSWORD }}
docker build -t ${{ secrets.DOCKER_USERNAME }}/embitips_front .
docker push ${{ secrets.DOCKER_USERNAME }}/embitips_front

- name: Deploy to GCP
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.HOST_PROD }}
username: ${{ secrets.USERNAME }}
key: ${{ secrets.PRIVATE_KEY }}
script: |
sudo docker stop embitips_front || true
sudo docker rm embitips_front || true
sudo docker pull ${{ secrets.DOCKER_USERNAME }}/embitips_front
sudo docker run -d -p 3000:3000 --name embitips_front ${{ secrets.DOCKER_USERNAME }}/embitips_front
sudo docker image prune -f
run: npm run build
52 changes: 52 additions & 0 deletions .github/workflows/cicd.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: 빌드 자동화

on:
push:
branches:
- main
- feat/cicd

jobs:
build:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Set up Node.js (언어 환경)
uses: actions/setup-node@v2
with:
node-version: "20"

- name: Install dependencies
run: |
npm install
npm install tailwindcss@latest postcss@latest autoprefixer@latest
npm install --save-dev @types/node

- name: Create .env file # env 파일 생성 단계 추가
run: |
echo "VITE_GA_MEASUREMENT_ID=${{ secrets.VITE_GA_MEASUREMENT_ID }}" > .env

- name: Run build
run: npm run build # 프로젝트에 맞는 빌드 명령어

- name: Docker build & push
run: |
docker login -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKER_PASSWORD }}
docker build -t ${{ secrets.DOCKER_USERNAME }}/embitips_front .
docker push ${{ secrets.DOCKER_USERNAME }}/embitips_front

- name: Deploy to GCP
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.HOST_PROD }}
username: ${{ secrets.USERNAME }}
key: ${{ secrets.PRIVATE_KEY }}
script: |
sudo docker stop embitips_front || true
sudo docker rm embitips_front || true
sudo docker pull ${{ secrets.DOCKER_USERNAME }}/embitips_front
sudo docker run -d -p 3000:3000 --name embitips_front ${{ secrets.DOCKER_USERNAME }}/embitips_front
sudo docker image prune -f
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"build": "vite build --mode production",
"lint": "eslint .",
"preview": "vite preview",
"start": "vite --port 3000"
"start": "vite --port 3000 --mode production"
},
"dependencies": {
"@tailwindcss/vite": "^4.0.3",
Expand Down