Skip to content

feat: add chat page #78

feat: add chat page

feat: add chat page #78

Workflow file for this run

name: Frontend CI/CD
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
permissions:
contents: read
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
cache: 'npm'
- name: Install dependencies
run: npm install
- name: Build frontend
run: npm run build
- name: Log in to Docker Hub
run: echo "${{ secrets.DOCKERHUB_PASSWORD }}" | docker login -u "${{ secrets.DOCKERHUB_USERNAME }}" --password-stdin
- name: Build Docker image
run: docker build -t ${{ secrets.DOCKERHUB_USERNAME }}/frontend:latest .
- name: Push Docker image to Docker Hub
run: docker push ${{ secrets.DOCKERHUB_USERNAME }}/frontend:latest
deploy:
runs-on: ubuntu-latest
needs: build
steps:
- name: Deploy to server
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.HOST }}
username: ubuntu
key: ${{ secrets.KEY }}
envs: GITHUB_SHA
script: |
cd /home/ubuntu
# 실행 중인 모든 컨테이너 정리
echo "🛑 Stopping all running containers..."
sudo docker rm -f $(docker ps -qa) || true
# 백엔드 이미지 가져오기
echo "🚀 Pulling the latest backend Docker image..."
sudo docker pull ${{ secrets.DOCKERHUB_USERNAME }}/blaybus:latest
# 프론트엔드 이미지 가져오기
echo "🚀 Pulling the latest frontend Docker image..."
sudo docker pull ${{ secrets.DOCKERHUB_USERNAME }}/frontend:latest
# 기존 컨테이너 종료 및 네트워크 정리
echo "🛑 Stopping and removing existing containers..."
docker-compose down
# 최신 이미지 적용
echo "🚀 Updating to the latest images..."
docker-compose pull
# 컨테이너 실행
echo "🚀 Starting the new containers..."
docker-compose up -d --build --force-recreate --no-deps
# 사용하지 않는 이미지 정리
echo "🧹 Cleaning up old images..."
docker image prune -f