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

CD 파이프라인 추가 #50

Merged
merged 6 commits into from
Jan 20, 2024
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
54 changes: 54 additions & 0 deletions .github/workflows/CICD_dev_be_merge.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: Spring Boot & Gradle CICD Jobs (With. dev branches push)

on:
push:
branches: [ dev ]

jobs:
build:
# 실행 환경 (Git Runners 개인 서버)
runs-on: self-hosted
steps:
- uses: actions/checkout@v3
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'adopt'

# application.yml 파일 설정
- name: resources 폴더 생성
run: |
mkdir -p ./backend/src/main/resources

- name: yml 파일 생성
run: |
echo "${{ secrets.APPLICATION_DEFAULT_DEV }}" > ./backend/src/main/resources/application.yml
echo "${{ secrets.APPLICATION_DEV }}" > ./backend/src/main/resources/application-dev.yml
echo "${{ secrets.APPLICATION_DB }}" > ./backend/src/main/resources/database.yml

# gradlew를 실행시키기 위해 권한 부여
- name: Gradlew에게 실행권한 부여
run: chmod +x ./backend/gradlew

# 멀티모듈 빌드하기
- name: 멀티모듈 전체 빌드
run: |
cd ./backend
./gradlew clean build -x test

deployment:
name: docker deployment
needs: build # depends on
runs-on: self-hosted

steps:
- name: 도커 컴포즈 복사
run: echo "${{ secrets.DOCKER_COMPOSE_DEV }}" > ./backend/docker-compose.yml

- name: 도커 컴포즈 재실행
run: |
cd ./backend
docker-compose down
docker rmi `docker images | grep gitudy | awk '{print $3}'`
docker-compose up -d
15 changes: 15 additions & 0 deletions .github/workflows/CI_dev_be_pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ jobs:

test:
runs-on: self-hosted
needs: build
steps:
- name: Gradle 테스트
run: |
Expand All @@ -49,3 +50,17 @@ jobs:
- name: yaml 파일 변경
run: |
echo "${{ secrets.APPLICATION_DEFAULT_DEV }}" > ./backend/src/main/resources/application.yml

coverage:
runs-on: self-hosted
needs: test
steps:
- name: 테스트 커버리지를 PR에 코멘트로 등록합니다
id: jacoco
uses: madrapps/[email protected]
with:
title: 📝 테스트 커버리지 리포트
paths: ${{ github.workspace }}/backend/build/reports/jacoco/test/jacocoTestReport.xml
token: ${{ secrets.GITHUB_TOKEN }}
min-coverage-overall: 50
min-coverage-changed-files: 50
11 changes: 11 additions & 0 deletions backend/Dockerfile-dev
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Dockerfile-dev
FROM openjdk:17-jdk-slim

ARG PROFILE
ENV PROFILE=${PROFILE}

ARG JAR_FILE=/build/libs/backend-0.0.1-SNAPSHOT.jar

COPY ${JAR_FILE} /app.jar

ENTRYPOINT ["java","-jar","-Dspring.profiles.active=${PROFILE}", "/app.jar"]
18 changes: 18 additions & 0 deletions backend/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ plugins {
id 'java'
id 'org.springframework.boot' version '3.2.1'
id 'io.spring.dependency-management' version '1.1.4'
id 'jacoco'
}

group = 'com.example'
Expand Down Expand Up @@ -67,3 +68,20 @@ dependencies {
tasks.named('test') {
useJUnitPlatform()
}

test {
finalizedBy jacocoTestReport
}

jacoco {
toolVersion = "0.8.11" // 버전 명시
}

jacocoTestReport {
dependsOn test
reports {
xml.required.set(true)
csv.required.set(false)
html.required.set(true)
}
}
Loading