From 9434bb7bbf5845f1d0a732df056f2cc6da376a58 Mon Sep 17 00:00:00 2001 From: dongyeoppp <103740881+dongyeoppp@users.noreply.github.com> Date: Wed, 24 Jul 2024 00:11:43 +0900 Subject: [PATCH 1/2] Update Spring Boot CI-CD.yml --- .github/workflows/Spring Boot CI-CD.yml | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/.github/workflows/Spring Boot CI-CD.yml b/.github/workflows/Spring Boot CI-CD.yml index 1434c7d..4492b6e 100644 --- a/.github/workflows/Spring Boot CI-CD.yml +++ b/.github/workflows/Spring Boot CI-CD.yml @@ -1,11 +1,13 @@ # Workflow 이름 -name: dongyeop CI/CD with Docker and EC2 +name: Spring Boot CI/CD with Docker and EC2 # 어떤 이벤트가 발생하면 workflow 실행할 지 명시 on: # main 브랜치와 dev 브랜치에 push나 pull request 발생 시 push: - branches: [ "feature/TSK-56/alarm" ] + branches: [ "main", "dev" ] + pull_request: + branches: [ "main", "dev" ] # 위 이벤트 발생 시 실행될 작업들 jobs: @@ -51,7 +53,7 @@ jobs: # 이미지 이름을 날짜와 함께 설정 - name: Set image name with date - run: echo "IMAGE_NAME=${{ secrets.DOCKERHUB_USERNAME }}/dongyeoppi:$(date +%Y%m%d%H%M%S)" >> $GITHUB_ENV + run: echo "IMAGE_NAME=${{ secrets.DOCKERHUB_USERNAME }}/${{ secrets.PROJECT_NAME }}:$(date +%Y%m%d%H%M%S)" >> $GITHUB_ENV # Docker 이미지 빌드 및 푸시 - name: Build and push Docker image @@ -91,9 +93,9 @@ jobs: id: read-image-name run: echo "IMAGE_NAME=$(cat image-name.txt)" >> $GITHUB_ENV -# # 프로젝트 이름을 환경 변수로 설정 -# - name: Set project name -# run: echo "PROJECT_NAME=dongyeoppi" >> $GITHUB_ENV + # 프로젝트 이름을 환경 변수로 설정 + - name: Set project name + run: echo "PROJECT_NAME=${{ secrets.PROJECT_NAME }}" >> $GITHUB_ENV # EC2에 SSH로 접속하여 배포 - name: SSH into EC2 and deploy @@ -111,7 +113,7 @@ jobs: sudo docker stop $EXISTING_CONTAINER sudo docker rm $EXISTING_CONTAINER fi - sudo docker run -d --name dongyeoppi -p 8081:8080 \ + sudo docker run -d --name ${{ env.PROJECT_NAME }} -p 8080:8080 \ -e SPRING_DATASOURCE_URL="${{ secrets.DB_URL }}" \ -e SPRING_DATASOURCE_USERNAME="${{ secrets.DB_USERNAME }}" \ -e SPRING_DATASOURCE_PASSWORD="${{ secrets.DB_PASSWORD }}" \ From 441091b29b9f9f115c1bee5f738b9c7caa8d5c1c Mon Sep 17 00:00:00 2001 From: dongyeoppp <103740881+dongyeoppp@users.noreply.github.com> Date: Wed, 24 Jul 2024 00:12:21 +0900 Subject: [PATCH 2/2] Update dongyeop CI-CD.yml --- .github/workflows/dongyeop CI-CD.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/dongyeop CI-CD.yml b/.github/workflows/dongyeop CI-CD.yml index 0613193..1434c7d 100644 --- a/.github/workflows/dongyeop CI-CD.yml +++ b/.github/workflows/dongyeop CI-CD.yml @@ -123,7 +123,6 @@ jobs: -e OPENAI_API_KEY="${{ secrets.OPENAI_API_KEY }}" \ -e FFMPEG_PATH="${{ secrets.FFMPEG_PATH }}" \ -e FFPROBE_PATH="${{ secrets.FFPROBE_PATH }}" \ -# -e FIREBASE_CONFIG_PATH="/app/resources/mooluck-fcm-firebase-adminsdk-cjwp5-cd30150b1a.json" \ ${{ env.IMAGE_NAME }} sudo docker ps -a sudo docker system prune -f