-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: CI/CD를 위한 workflow와 build.gradle.kts 정의
- Loading branch information
Showing
5 changed files
with
126 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
name: Docker CD | ||
|
||
on: | ||
push: | ||
branches: | ||
- 'master' | ||
|
||
jobs: | ||
# 서버 이미지를 생성합니다. | ||
Build-Upload-Image: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Check out repository code | ||
uses: actions/checkout@v2 | ||
with: | ||
# Git revision count를 구하기 위해 지난 모든 커밋 내역을 가져옵니다. | ||
fetch-depth: '0' | ||
|
||
- name: Set up JDK 11 | ||
uses: actions/setup-java@v1 | ||
with: | ||
java-version: 11 | ||
|
||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v1 | ||
|
||
- name: Grant execute permission for gradlew | ||
run: chmod +x gradlew | ||
|
||
# 프로젝트의 버전을 이미지 이름에 사용하여 하나 빌드하고, | ||
- name: Build bootBuildImage with version | ||
run: ./gradlew bootBuildImage -PdockerImageName=ghcr.io/inu-appcenter/inuit-server -PdockerUrl=https://ghcr.io -PdockerUsername=${{ secrets.DOCKER_USER }} -PdockerPassword=${{ secrets.DOCKER_TOKEN }} | ||
|
||
# "latest"를 이미지 이름에 사용하여 하나 빌드합니다. | ||
- name: Build bootBuildImage with latest | ||
run: ./gradlew bootBuildImage -PdockerImageName=ghcr.io/inu-appcenter/inuit-server -PdockerUrl=https://ghcr.io -PdockerUsername=${{ secrets.DOCKER_USER }} -PdockerPassword=${{ secrets.DOCKER_TOKEN }} -PdockerTag=latest |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
import java.io.ByteArrayOutputStream | ||
|
||
plugins { | ||
id("org.springframework.boot") version "2.5.0" | ||
id("io.spring.dependency-management") version "1.0.11.RELEASE" | ||
id("java") | ||
} | ||
|
||
val major = 0 | ||
val minor = 1 | ||
val patch = getRevisionCount() | ||
|
||
group = "pj" | ||
version = "$major.$minor.$patch" | ||
java.sourceCompatibility = JavaVersion.VERSION_11 | ||
|
||
configurations { | ||
compileOnly { | ||
extendsFrom(configurations.annotationProcessor.get()) | ||
} | ||
} | ||
|
||
repositories { | ||
mavenCentral() | ||
} | ||
|
||
dependencies { | ||
implementation ("org.springframework.boot:spring-boot-starter-data-jdbc") | ||
implementation ("mysql:mysql-connector-java") | ||
implementation ("org.springframework.boot:spring-boot-starter-data-jpa") | ||
implementation ("org.springframework.boot:spring-boot-starter-jdbc") | ||
implementation ("org.springframework.boot:spring-boot-starter-validation") | ||
implementation ("org.springframework.boot:spring-boot-starter-web") | ||
implementation ("org.springframework.boot:spring-boot-starter-mail") | ||
implementation ("org.springframework.boot:spring-boot-starter-security") | ||
implementation ("io.jsonwebtoken:jjwt:0.2") | ||
implementation ("io.springfox:springfox-boot-starter:3.0.0") | ||
compileOnly ("org.projectlombok:lombok") | ||
runtimeOnly ("com.h2database:h2") | ||
runtimeOnly ("mysql:mysql-connector-java") | ||
annotationProcessor( "org.projectlombok:lombok") | ||
testImplementation ("org.springframework.boot:spring-boot-starter-test") | ||
} | ||
|
||
tasks.withType<Test> { | ||
useJUnitPlatform() | ||
} | ||
|
||
/**************************************************************** | ||
* Docker 이미지 빌드를 위한 설정입니다. | ||
****************************************************************/ | ||
|
||
val dockerUrl: String? by project | ||
val dockerImageName: String? by project | ||
val dockerUsername: String? by project | ||
val dockerPassword: String? by project | ||
val dockerTag: String? by project | ||
|
||
tasks.bootBuildImage { | ||
imageName = "${dockerImageName ?: project.name}:${dockerTag ?: project.version}" | ||
|
||
print("[bootBuildImage] 이미지 이름: $imageName") | ||
|
||
if (dockerUrl != null) { | ||
isPublish = true | ||
docker { | ||
publishRegistry { | ||
url = dockerUrl | ||
username = dockerUsername | ||
password = dockerPassword | ||
} | ||
} | ||
} | ||
} | ||
|
||
/** | ||
* Git 리비전 카운트를 가져옵니다. | ||
* 이 카운트를 버전으로 사용합니다. | ||
*/ | ||
fun getRevisionCount(): Int { | ||
val byteOut = ByteArrayOutputStream() | ||
project.exec { | ||
commandLine = "git rev-list --count HEAD".split(" ") | ||
standardOutput = byteOut | ||
} | ||
val output = String(byteOut.toByteArray()) | ||
|
||
return Integer.parseInt(output.trim()) | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
rootProject.name = "circles" |