Skip to content

Commit cc6f1b6

Browse files
committed
ci/cd & build.gradle & application.yml
1 parent f4c4caf commit cc6f1b6

3 files changed

Lines changed: 76 additions & 6 deletions

File tree

.github/workflows/dev_deploy.yml

Lines changed: 61 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,66 @@
1-
name: BookLog CI/CD # 여러분들 맘대로 이름 지으세요
1+
name: CI/CD Pipeline
22

33
on:
4-
pull_request:
5-
types: [closed]
6-
workflow_dispatch: # (2).수동 실행도 가능하도록
4+
push:
5+
branches: [ dev ] # develop 브랜치에 push가 일어날 때 실행
76

87
jobs:
98
build:
10-
runs-on: ubuntu-latest # (3).OS환경
11-
if: github.event.pull_request.merged == true && github.event.pull_request.base.ref == 'develop'
9+
runs-on: ubuntu-latest
10+
11+
steps:
12+
- uses: actions/checkout@v3 # 저장소 코드 체크아웃
13+
14+
- name: Set up JDK 17 # Java 개발 킷 설정
15+
uses: actions/setup-java@v3
16+
with:
17+
distribution: 'temurin'
18+
java-version: '17'
19+
20+
- name: Make application.yml # application.yml 파일 생성
21+
run: |
22+
cd ./src/main/resources
23+
echo "${{ secrets.APPLICATION_YML }}" > ./application.yml
24+
shell: bash
25+
26+
- name: Grant execute permission for gradlew # gradlew 실행 권한 부여
27+
run: chmod +x gradlew
28+
29+
- name: Build with Gradle # Gradle을 사용하여 프로젝트 빌드
30+
uses: gradle/gradle-build-action@v2
31+
with:
32+
arguments: build
33+
34+
- name: Upload build artifact # 빌드된 아티팩트 업로드
35+
uses: actions/upload-artifact@v3
36+
with:
37+
name: booklog-server
38+
path: build/libs/*.jar
39+
40+
deploy:
41+
needs: build # build 작업이 성공적으로 완료된 후 실행
42+
runs-on: ubuntu-latest
43+
44+
steps:
45+
- name: Download build artifact # 이전 단계에서 업로드한 아티팩트 다운로드
46+
uses: actions/download-artifact@v3
47+
with:
48+
name: booklog-server
49+
path: build/libs/
50+
51+
- name: Deploy to EC2 # EC2에 배포
52+
env:
53+
EC2_SSH_KEY: ${{ secrets.EC2_SSH_KEY }}
54+
EC2_USERNAME: ${{ secrets.EC2_USERNAME }}
55+
EC2_HOST: ${{ secrets.EC2_HOST }}
56+
run: |
57+
echo "$EC2_SSH_KEY" > private_key.pem
58+
chmod 600 private_key.pem
59+
jar_file=$(find build/libs -name '*.jar' ! -name '*plain.jar' | head -n 1)
60+
scp -i private_key.pem -o StrictHostKeyChecking=no "$jar_file" $EC2_USERNAME@$EC2_HOST:/home/$EC2_USERNAME/umc7thServer.jar
61+
ssh -i private_key.pem -o StrictHostKeyChecking=no $EC2_USERNAME@$EC2_HOST "
62+
pgrep java | xargs -r kill -15 # 기존에 실행 중인 Java 프로세스 종료
63+
sleep 10
64+
nohup java -jar /home/$EC2_USERNAME/umc7thServer.jar > app.log 2>&1 & # 새 버전 애플리케이션 실행
65+
"
66+
rm -f private_key.pem # 민감한 정보 삭제

.idea/.name

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

booklog/build.gradle

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,3 +57,17 @@ dependencies {
5757
tasks.named('test') {
5858
useJUnitPlatform()
5959
}
60+
61+
def querydslDir = "src/main/generated"
62+
63+
sourceSets {
64+
main.java.srcDirs += [ querydslDir ]
65+
}
66+
67+
tasks.withType(JavaCompile) {
68+
options.annotationProcessorGeneratedSourcesDirectory = file(querydslDir)
69+
}
70+
71+
clean.doLast {
72+
file(querydslDir).deleteDir()
73+
}

0 commit comments

Comments
 (0)