From 12e46241fe19b009a16f672310f830e632034a1b Mon Sep 17 00:00:00 2001 From: nahjjun Date: Sun, 4 Jan 2026 15:46:22 +0900 Subject: [PATCH] =?UTF-8?q?:wrench:=20Setting:application-dev.yml=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80=20&=20dev=5Fdeploy.yml=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/dev_deploy.yml | 60 +++++++++++++++++++++++++- build.gradle | 2 +- src/main/resources/application-dev.yml | 27 ++++++++++++ 3 files changed, 86 insertions(+), 3 deletions(-) create mode 100644 src/main/resources/application-dev.yml diff --git a/.github/workflows/dev_deploy.yml b/.github/workflows/dev_deploy.yml index 730fc8d..8af4ef8 100644 --- a/.github/workflows/dev_deploy.yml +++ b/.github/workflows/dev_deploy.yml @@ -1,10 +1,66 @@ name: UMC Dev CI/CD on: pull_request: - types: [closed] # pr이 닫혔을 때만 실행되도록 설정 + branches: [ develop ] # develop 브랜치에 pr이 일어날 때 실행 + types: [closed] # 해당 pr이 닫혔을 때만 실행되도록 설정 workflow_dispatch: # (2).수동 실행도 가능하도록 jobs: build: runs-on: ubuntu-latest # (3).OS환경 - if: github.event.pull_request.merged == true && github.event.pull_request.base.ref == 'develop' \ No newline at end of file + if: github.event.pull_request.merged == true && github.event.pull_request.base.ref == 'develop' # 닫힌 pr이 성공적으로 합쳐졌을 때, 그리고 base ref가 develop일 때만 되도록 설정 + + steps: + - uses: actions/checkout@v3 # 저장소 코드 체크아웃 + - name: Set up JDK 21 # Java 개발 킷 설정 + uses: actions/setup-java@v3 + with: + distribution: 'temurin' + java-version: '21' + + - name: Make application-dev.yml # application-dev.yml 파일 생성 + run: | + cd ./src/main/resources + echo "${{ secrets.APPLICATION_DEV_YML }}" > ./application-dev.yml + shell: bash + + - name: Grant execute permission for gradlew # gradlew 실행 권한 부여 + run: chmod +x gradlew + + - name: Build with Gradle # Gradle을 사용하여 프로젝트 빌드 + uses: gradle/gradle-build-action@v2 + with: + arguments: build + + - name: Upload build artifact # 빌드된 아티팩트 업로드 + uses: actions/upload-artifact@v3 + with: + name: umc9thServer + path: build/libs/*.jar + deploy: + needs: build # build 작업이 성공적으로 완료된 후 실행 + runs-on: ubuntu-latest + + steps: + - name: Download build artifact # 이전 단계에서 업로드한 아티팩트 다운로드 + uses: actions/download-artifact@v3 + with: + name: umc9thServer + path: build/libs/ + + - name: Deploy to EC2 # EC2에 배포 + env: + EC2_SSH_KEY: ${{ secrets.EC2_SSH_KEY }} + EC2_USERNAME: ${{ secrets.EC2_USERNAME }} + EC2_HOST: ${{ secrets.EC2_HOST }} + run: | + echo "$EC2_SSH_KEY" > private_key.pem + chmod 600 private_key.pem + jar_file=$(find build/libs -name '*.jar' ! -name '*plain.jar' | head -n 1) + scp -i private_key.pem -o StrictHostKeyChecking=no "$jar_file" $EC2_USERNAME@$EC2_HOST:/home/$EC2_USERNAME/umc7thServer.jar + ssh -i private_key.pem -o StrictHostKeyChecking=no $EC2_USERNAME@$EC2_HOST " + pgrep java | xargs -r kill -15 # 기존에 실행 중인 Java 프로세스 종료 + sleep 10 + nohup java -jar /home/$EC2_USERNAME/umc7thServer.jar > app.log 2>&1 & # 새 버전 애플리케이션 실행 + " + rm -f private_key.pem # 민감한 정보 삭제 \ No newline at end of file diff --git a/build.gradle b/build.gradle index 9efb4ea..e09c0e5 100644 --- a/build.gradle +++ b/build.gradle @@ -97,7 +97,7 @@ sourceSets { } tasks.withType(JavaCompile).configureEach { - options.annotationProcessorGeneratedSourcesDirectory = querydslDir + options.annotationProcessorGeneratedSourcesDirectory = file(querydslDir) } clean.doLast { diff --git a/src/main/resources/application-dev.yml b/src/main/resources/application-dev.yml new file mode 100644 index 0000000..491f136 --- /dev/null +++ b/src/main/resources/application-dev.yml @@ -0,0 +1,27 @@ +spring: + application: + name: "UMC_SpringBoot" # "umc9th" + datasource: + driver-class-name: com.mysql.cj.jdbc.Driver # MySQL JDBC 드라이버 클래스 이름 + url: jdbc:mysql://umc-springboot.c382m2oykhbj.ap-northeast-2.rds.amazonaws.com:3306/umc_springboot?serverTimezone=Asia/Seoul + username: root + password: skgudwns1125 + + jpa: + database: mysql # 사용할 데이터베이스 유형 지정 (MySQL) + database-platform: org.hibernate.dialect.MySQLDialect # Hibernate에서 사용할 MySQL 방언(dialect) 설정 + show-sql: true # 실행된 SQL 쿼리를 콘솔에 출력할지 여부 설정 + hibernate: + ddl-auto: create # 애플리케이션 실행 시 데이터베이스 스키마의 상태를 설정, -> 첫 배포할 때는 create로 설정 + properties: + hibernate: + format_sql: true # 출력되는 SQL 쿼리를 보기 좋게 포맷팅 + +server: + servlet: + session: + timeout: 30m # 세션 유효 시간(기본값: 30분). 30분 동안 활동 없으면 삭제됨 + cookie: + max-age: 1800 # 쿠키 유효 시간 (초 단위). 보통 timeout과 맞춤 + http-only: true # js로 쿠키 접근 불가하도록 하는 설정 + secure: false # 로컬 개발(http)이므로 false. 배포(https) 시 true로 변경 \ No newline at end of file