From 563fbc30fc06a766042750675858f0324c49d4e4 Mon Sep 17 00:00:00 2001 From: ParkYunHo Date: Wed, 28 Jun 2023 16:08:01 +0900 Subject: [PATCH] =?UTF-8?q?:sparkles:feature=20:=20=EB=B0=B0=ED=8F=AC?= =?UTF-8?q?=ED=99=98=EA=B2=BD=20=EC=84=A4=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - jib 설정 - gitaction 설정 --- .github/workflows/ci.yaml | 33 +++++++++++++++++++++++++++++++++ api/build.gradle.kts | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 67 insertions(+) create mode 100644 .github/workflows/ci.yaml diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml new file mode 100644 index 0000000..116e4d1 --- /dev/null +++ b/.github/workflows/ci.yaml @@ -0,0 +1,33 @@ +name: CI + +on: + push: + tags: + - 'v**' + +# TODO: +# - gitaction에서 SSH 방식으로 인스턴스 접근해서 image pull & docker run 해보기 - https://doooodle932.tistory.com/163 +# - 수동으로 gitaction 돌릴 수 있도록 설정, if문 설정하면 될듯 (api, batch 별도 배포를 위해) - https://velog.io/@gidskql6671/Github-Actions-Job%EB%93%A4%EC%9D%98-%EC%8B%A4%ED%96%89-%EC%88%9C%EC%84%9C-%EC%A0%95%ED%95%B4%EC%A3%BC%EA%B8%B0 +jobs: + ci: + runs-on: ubuntu-latest + steps: + - name: git checkout + uses: actions/checkout@v2 + + - name: Setup JDK + uses: actions/setup-java@v1 + with: + java-version: 17 + + - name: Grant execute permission for gradlew + run: chmod +x gradlew + + - name: docker login + uses: docker/login-action@v2 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - name: Build Gradle with JIB + run: ./gradlew clean --stacktrace -PtagName=$GITHUB_REF_NAME --build-file=./api/build.gradle.kts -Djib.console=plain -Djib.useOnlyProjectCache=true jib \ No newline at end of file diff --git a/api/build.gradle.kts b/api/build.gradle.kts index 62834fa..93a038f 100644 --- a/api/build.gradle.kts +++ b/api/build.gradle.kts @@ -19,3 +19,37 @@ dependencies { testImplementation("io.projectreactor:reactor-test") } + +// JIB 설정 +val tagName = project.properties["tagName"] +val regex = Regex("^v") + +jib { + from { + image = "eclipse-temurin:17" + } + to { + image = "johnpark0921/lotto-portfolio:$tagName" +// if(regex.containsMatchIn(tagName as String)) { +// tags = setOf("latest") +// } + } + container { + labels.set( + mapOf( + "maintainer" to "yoonho " + ) + ) + creationTime.set("USE_CURRENT_TIMESTAMP") + setFormat("OCI") + environment = mapOf( + "TZ" to "Asia/Seoul" + ) + jvmFlags = listOf( + "-Dsun.net.inetaddr.ttl=0", // DNS cache TTL + "-XX:+PrintCommandLineFlags", // Print JVM Flags + ) + } +} + +