Skip to content

Commit

Permalink
Merge pull request #182 from yudonggeun/chore/cd-actions
Browse files Browse the repository at this point in the history
[infra] domain 적용 및 ci actions 추가
  • Loading branch information
yudonggeun authored Jun 18, 2024
2 parents 45630c4 + 3627418 commit 12f7acf
Show file tree
Hide file tree
Showing 7 changed files with 58 additions and 9 deletions.
26 changes: 26 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: CI

on:
push:
branches: [ main ] # push 되었을 때, 실행

jobs:
cd:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

# jdk 21 환경 구성
- name: set up jdk 21
uses: actions/setup-java@v4
with:
distribution: 'zulu'
java-version: '21'

# Gradle wrapper 파일 실행 권한주기
- name: Grant execute permission for gradlew
run: chmod +x gradlew

# Gradle jib를 통한 이미지 배포
- name: update image using jib
run: ./gradlew --info jib
4 changes: 2 additions & 2 deletions auth/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ tasks.asciidoctor {
dependsOn(tasks.test)
}

val hostname = "152.70.145.249"
val hostname = "kpring.duckdns.org"

openapi3 {
setServer("http://$hostname/auth")
Expand All @@ -94,7 +94,7 @@ jib {
to {
image = "youdong98/kpring-auth-application"
setAllowInsecureRegistries(true)
tags = setOf("latest")
tags = setOf("latest", version.toString())
}
container {
jvmFlags = listOf("-Xms512m", "-Xmx512m")
Expand Down
25 changes: 24 additions & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
import org.springframework.boot.gradle.tasks.bundling.BootJar
import java.io.IOException

plugins {
id("org.springframework.boot") version "3.2.4"
Expand All @@ -17,7 +18,7 @@ repositories {

allprojects {
group = "com.sideproject"
version = "0.0.1-SNAPSHOT"
version = "git rev-parse --short=8 HEAD".runCommand(workingDir = rootDir)

repositories {
mavenCentral()
Expand Down Expand Up @@ -53,3 +54,25 @@ subprojects {
debug.set(true)
}
}

/**
* cli 실행 결과를 반환한기 위한 함수
*/
fun String.runCommand(
workingDir: File = File("."),
timeoutAmount: Long = 60,
timeoutUnit: TimeUnit = TimeUnit.SECONDS,
): String =
ProcessBuilder(split("\\s(?=(?:[^'\"`]*(['\"`])[^'\"`]*\\1)*[^'\"`]*$)".toRegex()))
.directory(workingDir)
.redirectOutput(ProcessBuilder.Redirect.PIPE)
.redirectError(ProcessBuilder.Redirect.PIPE)
.start()
.apply { waitFor(timeoutAmount, timeoutUnit) }
.run {
val error = errorStream.bufferedReader().readText().trim()
if (error.isNotEmpty()) {
throw IOException(error)
}
inputStream.bufferedReader().readText().trim()
}
2 changes: 1 addition & 1 deletion infra/compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ services:
ports:
- "8080:8080"
environment:
URLS: "[{name: 'auth', url: 'http://152.70.145.249/auth/static/openapi3.yaml'},{name: 'user', url: 'http://152.70.145.249/user/static/openapi3.yaml'}, {name: 'server', url: 'http://152.70.145.249/server/static/openapi3.yaml'}]"
URLS: "[{name: 'auth', url: 'http://kpring.duckdns.org/auth/static/openapi3.yaml'},{name: 'user', url: 'http://kpring.duckdns.org/user/static/openapi3.yaml'}, {name: 'server', url: 'http://kpring.duckdns.org/server/static/openapi3.yaml'}]"
4 changes: 2 additions & 2 deletions server/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ kapt {
annotationProcessor("org.springframework.data.mongodb.repository.support.MongoAnnotationProcessor")
}

val hostname = "152.70.145.249"
val hostname = "kpring.duckdns.org"

openapi3 {
setServer("http://$hostname/server")
Expand All @@ -91,7 +91,7 @@ jib {
to {
image = "youdong98/kpring-server-application"
setAllowInsecureRegistries(true)
tags = setOf("latest")
tags = setOf("latest", version.toString())
}
container {
jvmFlags = listOf("-Xms512m", "-Xmx512m")
Expand Down
2 changes: 1 addition & 1 deletion server/src/main/kotlin/kpring/server/util/DtoMapper.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import kpring.core.server.dto.ServerThemeInfo
import kpring.server.domain.Category
import kpring.server.domain.Theme

fun Category.toInfo(): CategoryInfo {
fun Category.toInfo(): CategoryInfo {
return CategoryInfo(
id = this.name,
name = this.toString(),
Expand Down
4 changes: 2 additions & 2 deletions user/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ dependencies {
implementation("org.springframework.restdocs:spring-restdocs-asciidoctor")
}

val hostname = "152.70.145.249"
val hostname = "kpring.duckdns.org"

openapi3 {
setServer("http://$hostname/user")
Expand All @@ -75,7 +75,7 @@ jib {
to {
image = "youdong98/kpring-user-application"
setAllowInsecureRegistries(true)
tags = setOf("latest")
tags = setOf("latest", version.toString())
}
container {
jvmFlags = listOf("-Xms512m", "-Xmx512m")
Expand Down

0 comments on commit 12f7acf

Please sign in to comment.