Skip to content

Commit f2b5fc2

Browse files
committed
Merge branch 'develop' into feature/comment-read
2 parents e5b3787 + b6ff618 commit f2b5fc2

File tree

9 files changed

+114
-26
lines changed

9 files changed

+114
-26
lines changed

.github/workflows/ci.cd.prod.yml

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,9 @@ on:
77
types:
88
- closed
99
workflow_dispatch: # 수동 실행 가능
10-
11-
1210
# 병합됐을 때
1311
jobs:
14-
deploy:
12+
build:
1513
runs-on: ubuntu-latest
1614
steps:
1715
# 체크아웃
@@ -61,24 +59,27 @@ jobs:
6159
with:
6260
arguments: clean build -x test
6361

62+
deploy:
63+
runs-on: ubuntu-latest
64+
if: github.event.pull_request.merged == true
65+
needs: build
66+
steps:
67+
- uses: actions/checkout@v4
6468

6569
# 빌드 결과물을 S3 버킷에 업로드
6670
- name: Upload to AWS S3
6771
run: |
6872
echo "S3 Location: s3://${{ secrets.S3_BUCKET_NAME }}/$GITHUB_SHA.zip"
6973
aws deploy push \
70-
--application-name ${{ secrets.CODE_DEPLOY_APP_NAME }} \
71-
--ignore-hidden-files \
72-
--s3-location s3://${{ secrets.S3_BUCKET_NAME }}/prod/${{ github.sha }}.zip \
73-
--source .
74-
74+
--application-name ${{ secrets.CODE_DEPLOY_APP_NAME }} \
75+
--ignore-hidden-files \
76+
--s3-location s3://${{ secrets.S3_BUCKET_NAME }}/prod/${{ github.sha }}.zip \
77+
--source .
7578
# S3 버킷에 있는 파일을 대상으로 CodeDeploy 실행
7679
- name: Deploy to AWS EC2 from S3g
7780
run: |
7881
aws deploy create-deployment \
7982
--application-name ${{ secrets.CODE_DEPLOY_APP_NAME }} \
8083
--deployment-config-name CodeDeployDefault.AllAtOnce \
8184
--deployment-group-name ${{ secrets.CODE_DEPLOY_DEPLOYMENT_GROUP_NAME }} \
82-
--s3-location bucket=${{ secrets.S3_BUCKET_NAME }},key=prod/${{ github.sha }}.zip,bundleType=zip
83-
84-
85+
--s3-location bucket=${{ secrets.S3_BUCKET_NAME }},key=prod/${{ github.sha }}.zip,bundleType=zip
Lines changed: 36 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,10 @@
1-
name: log4u-build
1+
name: log4u-dev-build
22
on:
3-
# push:
4-
# branches:
5-
# - develop # dev 브랜치 push
63
pull_request:
74
branches:
8-
- main # main pr
95
- develop # develop pr
106
types: [ opened, synchronize, reopened ]
7+
workflow_dispatch:
118
jobs:
129
build:
1310
name: Build and analyze
@@ -16,30 +13,59 @@ jobs:
1613
- uses: actions/checkout@v4
1714
with:
1815
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
16+
1917
- name: Set up JDK 21
2018
uses: actions/setup-java@v4
2119
with:
2220
java-version: 21
2321
distribution: 'zulu' # Alternative distribution options are available
22+
2423
- name: Cache Gradle packages
2524
uses: actions/cache@v4
2625
with:
2726
path: ~/.gradle/caches
2827
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }}
2928
restore-keys: ${{ runner.os }}-gradle
29+
3030
- name: Cache SonarCloud packages
3131
uses: actions/cache@v4
3232
with:
3333
path: ~/.sonar/cache
3434
key: ${{ runner.os }}-sonar
3535
restore-keys: ${{ runner.os }}-sonar
36+
37+
38+
- name: MySQL 컨테이너 실행
39+
run: |
40+
docker run --name test-mysql \
41+
-e MYSQL_ROOT_PASSWORD=root \
42+
-e MYSQL_DATABASE=log4u \
43+
-e MYSQL_USER=dev \
44+
-e MYSQL_PASSWORD=devcos4-team08 \
45+
-d \
46+
-p 3307:3306 \
47+
mysql:8.0.33
48+
3649
- name: Build and analyze
3750
env:
38-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
51+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
3952
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
40-
DB_URL: ${{ secrets.DB_URL }} # Database URL
41-
DB_USERNAME: ${{ secrets.DB_USERNAME }} # Database username
42-
DB_PASSWORD: ${{ secrets.DB_PASSWORD }} # Database password
53+
DB_URL: jdbc:mysql://localhost:3307/log4u
54+
DB_USERNAME: dev
55+
DB_PASSWORD: devcos4-team08
56+
57+
# dev 프로필 사용
4358
run: |
4459
chmod +x ./gradlew
45-
./gradlew build jacocoTestReport sonar --info -Dsonar.branch.name=${{ github.ref_name }}
60+
./gradlew build jacocoTestReport sonar --info -Pprofile=dev -Dsonar.branch.name=${{ github.ref_name }}
61+
62+
- name: Docker MySQL 종료 및 제거
63+
run: |
64+
docker stop log4u-mysql
65+
docker rm log4u-mysql
66+
67+
- name: Upload Test Report
68+
uses: actions/upload-artifact@v4
69+
with:
70+
name: problems-report
71+
path: build/reports/problems/problems-report.html

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,3 +35,4 @@ out/
3535

3636
### VS Code ###
3737
.vscode/
38+
/src/main/resources/application-secret.yml

README.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
## 개발 환경 설정
2+
3+
* 루트 디렉토리(WEB3_4_Log4U_BE)에서 다음 명령 실행
4+
5+
6+
* 개발용 MYSQL 빌드
7+
8+
```
9+
# 이미지 빌드
10+
cd docker
11+
docker build -t log4u-mysql .
12+
13+
# 최초 실행 1(볼륨 존재)
14+
docker run -d --name log4u-mysql -p 3307:3306 -v {file}:/var/lib/mysql log4u-mysql
15+
16+
# 최초 실행 2(볼륨 없이)
17+
docker run -d --name log4u-mysql -p 3307:3306 log4u-mysql
18+
19+
# 이미 존재할 경우
20+
docker start log4u-mysql
21+
22+
```

docker/Dockerfile

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# MYSQL
2+
FROM mysql:8.0.33
3+
4+
# 변수 설정
5+
ENV TZ=Asia/Seoul \
6+
MYSQL_ROOT_PASSWORD=root \
7+
MYSQL_USER=dev \
8+
MYSQL_PASSWORD=devcos4-team08 \
9+
MYSQL_DATABASE=log4u
10+
11+
# 데이터 파일을 컨테이너에 연결
12+
VOLUME ["/var/lib/mysql"]
13+
14+
# MySQL 3306 포트
15+
EXPOSE 3306
16+
17+
# MYSQL 실행
18+
CMD ["mysqld"]
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
logging:
2+
level:
3+
org:
4+
springframework: debug
5+
6+
spring:
7+
jpa:
8+
database-platform: org.hibernate.dialect.MySQLDialect
9+
hibernate:
10+
ddl-auto: create
11+
12+
datasource:
13+
url: jdbc:mysql://localhost:3307/log4u
14+
username: dev
15+
password: devcos4-team08
16+
driver-class-name: com.mysql.cj.jdbc.Driver

src/main/resources/application.properties

Whitespace-only changes.

src/main/resources/application.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
logging:
2+
level:
3+
org:
4+
springframework: debug
5+
16
spring:
27
profiles:
38
include: secret
@@ -9,7 +14,7 @@ spring:
914
driver-class-name: com.mysql.cj.jdbc.Driver
1015

1116
jpa:
12-
database-platform: org.hibernate.dialect.MySQL8Dialect
17+
database-platform: org.hibernate.dialect.MySQLDialect
1318
hibernate:
1419
ddl-auto: create
1520

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
package com.example.log4u;
22

3-
import org.junit.jupiter.api.Test;
43
import org.springframework.boot.test.context.SpringBootTest;
54

65
@SpringBootTest
76
class Log4UApplicationTests {
87

9-
@Test
10-
void contextLoads() {
11-
}
8+
// @Test
9+
// void contextLoads() {
10+
// }
1211

1312
}

0 commit comments

Comments
 (0)