test: 배포 테스트를 위한 임시 설정 #2
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: TOONPICK Backend CD | |
on: | |
push: | |
branches: | |
- main | |
- develop | |
jobs: | |
deploy: | |
runs-on: ubuntu-latest | |
steps: | |
- name: 저장소 체크아웃 | |
uses: actions/checkout@v3 | |
- name: Docker Build 및 Push | |
env: | |
DOCKER_HUB_USERNAME: ${{ secrets.DOCKER_HUB_USERNAME }} | |
DOCKER_HUB_PASSWORD: ${{ secrets.DOCKER_HUB_PASSWORD }} | |
REPOSITORY: "toonpick-service-app" | |
run: | | |
docker build -t $DOCKER_HUB_USERNAME/$REPOSITORY:latest ./backend | |
echo "$DOCKER_HUB_PASSWORD" | docker login -u "$DOCKER_HUB_USERNAME" --password-stdin | |
docker push $DOCKER_HUB_USERNAME/$REPOSITORY:latest | |
- name: EC2에 SSH 접속하여 배포 실행 | |
uses: appleboy/[email protected] | |
with: | |
host: ${{ secrets.SSH_HOST }} | |
username: ${{ secrets.SSH_USER }} | |
key: ${{ secrets.SSH_PRIVATE_KEY }} | |
script: | | |
cd ~/TOONPICK # 프로젝트 디렉터리 이동 | |
# 최신 이미지 Pull | |
docker pull ${{ secrets.DOCKER_HUB_USERNAME }}/toonpick-service-app:latest | |
# 기존 컨테이너 중지 및 삭제 | |
docker-compose down | |
# 최신 컨테이너 실행 | |
docker-compose up -d |