Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 58 additions & 2 deletions .github/workflows/dev_deploy.yml
Original file line number Diff line number Diff line change
@@ -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'
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 # 민감한 정보 삭제
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ sourceSets {
}

tasks.withType(JavaCompile).configureEach {
options.annotationProcessorGeneratedSourcesDirectory = querydslDir
options.annotationProcessorGeneratedSourcesDirectory = file(querydslDir)
}

clean.doLast {
Expand Down
27 changes: 27 additions & 0 deletions src/main/resources/application-dev.yml
Original file line number Diff line number Diff line change
@@ -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로 변경
Loading