-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This reverts commit 683bdf9.
- Loading branch information
Showing
1 changed file
with
23 additions
and
18 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,11 +3,11 @@ name: CI/CD Workflow for Develop | |
on: | ||
# PR 작성 및 업데이트 시 CI 실행 | ||
pull_request: | ||
branches: [ "deploy-#37" ] | ||
branches: [ "develop" ] | ||
|
||
# develop 브랜치로의 푸시 시 CD 실행 | ||
push: | ||
branches: [ "deploy-#37" ] | ||
branches: [ "develop" ] | ||
|
||
jobs: | ||
# 공통 설정 및 Gradle 빌드용 Setup job | ||
|
@@ -82,25 +82,30 @@ jobs: | |
- name: Push Docker image to Docker Hub | ||
run: docker push ${{ secrets.DOCKERHUB_USERNAME }}/${{ secrets.DOCKERHUB_IMAGE_NAME }} | ||
|
||
# EC2 서버에 Docker Compose로 배포 | ||
- name: Deploy to server | ||
uses: appleboy/ssh-action@master | ||
id: deploy | ||
# SSH 비밀 키 설정 | ||
- name: Install SSH Key | ||
uses: webfactory/[email protected] | ||
with: | ||
host: ${{ secrets.EC2_HOST }} | ||
username: ${{ secrets.EC2_USER }} | ||
key: ${{ secrets.EC2_KEY }} | ||
script: | | ||
ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }} | ||
|
||
# EC2 서버에 Docker Compose로 배포 | ||
- name: Deploy on EC2 | ||
env: | ||
EC2_HOST: ${{ secrets.EC2_HOST }} | ||
EC2_USER: ${{ secrets.EC2_USER }} | ||
run: | | ||
ssh -o StrictHostKeyChecking=no $EC2_USER@$EC2_HOST << EOF | ||
cd /home/ubuntu # docker-compose.yml 파일 위치로 이동 | ||
# 기존 컨테이너 중지 | ||
sudo docker-compose down | ||
docker-compose down | ||
# 사용 중인 이미지 제거 (캐시 무효화를 위해) | ||
sudo docker images -q ${{ secrets.DOCKERHUB_USERNAME }}/${{ secrets.DOCKERHUB_IMAGE_NAME }} | xargs -r sudo docker rmi | ||
docker images -q ${{ secrets.DOCKERHUB_USERNAME }}/${{ secrets.DOCKERHUB_IMAGE_NAME }} | xargs -r sudo docker rmi | ||
# 최신 이미지 pull | ||
sudo docker-compose pull ${{ secrets.DOCKERHUB_USERNAME }}/${{ secrets.DOCKERHUB_IMAGE_NAME }} | ||
docker-compose pull ${{ secrets.DOCKERHUB_USERNAME }}/${{ secrets.DOCKERHUB_IMAGE_NAME }} | ||
# 모든 서비스 다시 실행 | ||
sudo docker-compose up -d | ||
docker-compose up -d | ||
EOF |