Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CHORE] DEV_CD 파이프라인 구축 + application-dev.yml 작성 #58

Merged
merged 25 commits into from
Jan 23, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
0683e11
feat: application-dev.yml 작성
coli-geonwoo Jan 17, 2025
300bdb7
chore: 변수명 변경
coli-geonwoo Jan 17, 2025
e52221a
chore: Dev_CD.yml 스크립트 작성
coli-geonwoo Jan 17, 2025
7e1214d
chore: gradlew 권한 허용 추가
coli-geonwoo Jan 17, 2025
726a6ab
chore: jar 파일 경로 수정
coli-geonwoo Jan 17, 2025
eed7381
chore: root 명령어로 pid 추출
coli-geonwoo Jan 17, 2025
e335d5b
chore: root 명령어로 kill 명령어 호출
coli-geonwoo Jan 17, 2025
6d04069
chore: datasource 오타 수정
coli-geonwoo Jan 17, 2025
30a84d8
chore: ddl-auto 설정 변경
coli-geonwoo Jan 17, 2025
e0c7226
chore: ddl-auto 설정 변경
coli-geonwoo Jan 17, 2025
c376434
chore: application-local.yml 설정 변경
coli-geonwoo Jan 17, 2025
5c1f881
chore: actuator 추가
coli-geonwoo Jan 17, 2025
59c1678
chore: checkout branch 변경
coli-geonwoo Jan 17, 2025
17f9488
chore: 환경변수를 주입하도록 변경
coli-geonwoo Jan 17, 2025
7d64b83
chore: 환경변수를 주입하도록 변경
coli-geonwoo Jan 17, 2025
234840c
chore: pid 를 출력하도록 변경
coli-geonwoo Jan 17, 2025
46ae1fc
chore: kill process 수정
coli-geonwoo Jan 17, 2025
21b912a
chore: kill process 수정
coli-geonwoo Jan 17, 2025
9f2727a
chore: kill process 수정
coli-geonwoo Jan 17, 2025
070b61a
chore: 스크립트 분리
coli-geonwoo Jan 17, 2025
a4a6a87
chore: 스크립트 분리
coli-geonwoo Jan 17, 2025
14cf8b7
chore: dev-secret.yml
coli-geonwoo Jan 17, 2025
ad80796
refactor: actuator 제거 및 트리거 복구
coli-geonwoo Jan 17, 2025
2450fd2
style: 불필요한 개행 삭제
coli-geonwoo Jan 19, 2025
9bc50d3
feat: 배포 파이프라인에 테스트 작업 추가
coli-geonwoo Jan 23, 2025
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
72 changes: 72 additions & 0 deletions .github/workflows/Dev_CD.yml
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

테스트를 수행하지 않고 바로 배포하네요. 테스트를 수행하지 않아도 괜찮다고 판단한 이유가 궁금해요!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

반영하였습니다.

Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
name: dev-cd

on:
push:
branches:
- "develop"

jobs:
build:
runs-on: ubuntu-latest

steps:
- name: Checkout Develop Branch
uses: actions/checkout@v4
with:
ref: "develop"

- name: Setting dev-secret.yml
run: |
echo "${{ secrets.DEV_SECRET_YML }}" > ./src/main/resources/dev-secret.yml

- name: Set up JDK 17
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '17'

- name: Make gradlew executable
run: chmod +x gradlew

- name: Clean And Test With Gradle
run: ./gradlew clean test

- name: bootJar with Gradle
run: ./gradlew bootJar --info

- name: Change artifact file name
run: mv build/libs/*.jar build/libs/app.jar

- name: Upload artifact file
uses: actions/upload-artifact@v4
with:
name: app-artifact
path: ./build/libs/app.jar
if-no-files-found: error

- name: Upload deploy scripts
uses: actions/upload-artifact@v4
with:
name: deploy-scripts
path: ./scripts/dev/
if-no-files-found: error

deploy:
needs: build
runs-on: dev

steps:
- name: Download artifact file
uses: actions/download-artifact@v4
with:
name: app-artifact
path: ~/app

- name: Download deploy scripts
uses: actions/download-artifact@v4
with:
name: deploy-scripts
path: ~/app/scripts

- name: Replace application to latest
run: sudo sh ~/app/scripts/replace-new-version.sh
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ dependencies {
testImplementation 'org.springframework.restdocs:spring-restdocs-restassured'
testImplementation 'com.epages:restdocs-api-spec-mockmvc:0.18.2'
testImplementation 'com.epages:restdocs-api-spec-restassured:0.18.2'

// Excel Export
implementation 'org.apache.poi:poi-ooxml:5.2.3'
implementation 'org.apache.poi:poi:5.2.3'
Expand Down
22 changes: 22 additions & 0 deletions scripts/dev/replace-new-version.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/bin/bash

PID=$(lsof -t -i:8080)

# 프로세스 종료
if [ -z "$PID" ]; then
echo "No process is using port 8080."
else
echo "Killing process with PID: $PID"
kill -15 "$PID"

# 직전 명령(프로세스 종료 명령)이 정상 동작했는지 확인
if [ $? -eq 0 ]; then
echo "Process $PID terminated successfully."
else
echo "Failed to terminate process $PID."
fi
fi

JAR_FILE=$(ls /home/ubuntu/app/*.jar | head -n 1)

sudo nohup java -Dspring.profiles.active=dev -Duser.timezone=Asia/Seoul -Dserver.port=8080 -jar "$JAR_FILE" &
16 changes: 16 additions & 0 deletions src/main/resources/application-dev.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
spring:
config:
import: dev-secret.yml
datasource:
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://${secret.datasource.url}:${secret.datasource.port}/${secret.datasource.database}?useUnicode=true&characterEncoding=utf8&allowPublicKeyRetrieval=true&autoReconnect=true&serverTimezone=Asia/Seoul&useLegacyDatetimeCode=false
username: ${secret.datasource.username}
password: ${secret.datasource.password}
jpa:
show-sql: true
properties:
hibernate:
format_sql: true
hibernate:
ddl-auto: update
defer-datasource-initialization: true
Empty file.
Loading