🎨 [design] 사용자 가이드 #262
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: React CI/CD | |
on: | |
push: | |
branches: ["dev"] | |
pull_request: | |
branches: ["dev"] | |
permissions: | |
contents: read | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Set up Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: '22.9.0' # Node.js 버전 설정 | |
- name: Install dependencies | |
run: npm ci # 의존성 설치 | |
- name: Build application | |
run: npm run build # 애플리케이션 빌드 | |
docker: | |
needs: build # build 작업이 성공적으로 완료된 후에만 실행 | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v2 | |
- name: Docker Login, image build and push | |
run: | | |
docker login -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKER_PASSWORD }} | |
docker build -t ${{ secrets.DOCKER_USERNAME }}/peachmentor:pm-react -f Dockerfile . | |
docker push ${{ secrets.DOCKER_USERNAME }}/peachmentor:pm-react # Docker Hub에 이미지 푸시 | |
- name: nginx docker build and push | |
run: | | |
docker build -t ${{ secrets.DOCKER_USERNAME }}/peachmentor:pm-nginx -f nginx/Dockerfile-nginx nginx | |
docker push ${{ secrets.DOCKER_USERNAME }}/peachmentor:pm-nginx | |
- name: executing remote ssh commands using password | |
uses: appleboy/ssh-action@master | |
with: | |
host: ${{ secrets.HOST }} | |
username: ubuntu | |
key: ${{ secrets.KEY }} | |
script: | | |
sudo docker rm -f react nginx | |
sudo docker pull ${{ secrets.DOCKER_USERNAME }}/peachmentor:pm-react | |
sudo docker pull ${{ secrets.DOCKER_USERNAME }}/peachmentor:pm-nginx | |
docker-compose up -d react nginx | |
docker image prune -f | |