From 9bb1f5466fd60e102f265133c81874d709ca5bbf Mon Sep 17 00:00:00 2001 From: Robert Wiesner Date: Mon, 23 May 2022 17:40:58 +0200 Subject: [PATCH] try gha only --- .github/workflows/gradle-build-push-image.yml | 12 ++++--- build.gradle.kts | 35 +------------------ 2 files changed, 8 insertions(+), 39 deletions(-) diff --git a/.github/workflows/gradle-build-push-image.yml b/.github/workflows/gradle-build-push-image.yml index 60d7531..152445d 100644 --- a/.github/workflows/gradle-build-push-image.yml +++ b/.github/workflows/gradle-build-push-image.yml @@ -78,16 +78,18 @@ jobs: cache: gradle - name: Grant execute permission for gradlew run: chmod +x gradlew - - - name: Log in to registry - run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u $ --password-stdin + - name: Build OCI with Gradle - run: ./gradlew bootBuildImage --imageName $IMAGE_NAME --publishImage + run: ./gradlew bootBuildImage --imageName ghcr.io/$IMAGE_NAME env: IMAGE_TAG_BRANCH_COMMIT: ${{ steps.image-tags.outputs.branch_commit_tag }} IMAGE_TAG_BRANCH: ${{ steps.image-tags.outputs.branch_tag }} - GHCR_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Log in to registry + run: | + echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u $ --password-stdin + docker push ghcr.io/$IMAGE_NAME build-push-image-dry-run: name: Build OCI Image (Dry Run) diff --git a/build.gradle.kts b/build.gradle.kts index 078df81..caa3b05 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,5 +1,4 @@ import org.jetbrains.kotlin.gradle.tasks.KotlinCompile -import org.springframework.boot.gradle.tasks.bundling.BootBuildImage plugins { id("org.springframework.boot") version "2.7.0" @@ -55,36 +54,4 @@ tasks.withType { ) jvmTarget = "17" } -} - -tasks.getByName("bootBuildImage") { - imageName = project.name - val repoName = "ghcr.io/rowi1de" - val fullName = "$repoName/$imageName" - val branchCommitHashTag: String? = - getEnvironmentVariable("IMAGE_TAG_BRANCH_COMMIT") - tags = listOfNotNull( - branchCommitHashTag - ).map { "$fullName:$it" } - .toList() - docker { - publishRegistry { - url = repoName - email = "hello@robert-wiesner.de" - token = requireNotNull(getEnvironmentVariable("GHCR_TOKEN")){"GHCR_TOKEN not set"} - } - } -} - -/** - * Get value from environment variables and return if not blank or null. - * @param name name of the environment variable - * @param default default if null or blank - * @return value or default - */ -fun getEnvironmentVariable(name: String, default: String? = null): String? = - System.getenv()[name].takeUnless { it.isNullOrBlank() } ?: default - -tasks.withType { - useJUnitPlatform() -} +} \ No newline at end of file