Skip to content

Refactor UI 개선 및 프로젝트 구조 정리 (#56) #23

Refactor UI 개선 및 프로젝트 구조 정리 (#56)

Refactor UI 개선 및 프로젝트 구조 정리 (#56) #23

name: Frontend CI/CD
# 이 워크플로가 실행될 조건: main 브랜치에 push가 발생했을 때
on:
push:
branches: ['develop']
jobs:
build-and-deploy:
runs-on: amazonlinux-2023
# frontend 디렉터리에서 작업이 실행되도록 기본 경로 설정
defaults:
run:
working-directory: ./frontend
steps:
# 1. 코드 체크아웃
- name: Checkout code
uses: actions/checkout@v4
# 2. Node.js 18.x 버전 설정
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: 18
# 3. 의존성 패키지 설치
- name: Install dependencies
run: npm ci
# 4. 프로덕션 빌드
- name: Build for production
run: npm run build
# 5. 빌드된 파일(dist)을 EC2 웹서버 루트로 전송
- name: Deploy to EC2
uses: appleboy/scp-action@master
with:
host: ${{ secrets.EC2_HOST }}
username: ${{ secrets.EC2_USERNAME }}
key: ${{ secrets.SSH_PRIVATE_KEY }}
source: './frontend/dist/*'
target: '/home/${{ secrets.EC2_USERNAME }}/frontend/dist'
# strip_components: 2 # source 경로에서 'frontend/dist' 부분을 제거