diff --git a/.github/workflows/backend_publish.yml b/.github/workflows/backend_publish.yml index 4d7ef7e..dc1bfa7 100644 --- a/.github/workflows/backend_publish.yml +++ b/.github/workflows/backend_publish.yml @@ -6,6 +6,7 @@ on: - main paths: - 'backend/**' + - '.github/workflows/backend_publish.yml' workflow_dispatch: # Manual trigger jobs: @@ -34,13 +35,11 @@ jobs: - name: Build and Publish Docker Image working-directory: backend - env: - GITHUB_ACTOR: ${{ github.actor }} - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | # Build the Docker image and tag it with both the 'latest', commit hash, and tag if exist ./gradlew bootBuildImage --imageName=ghcr.io/zabiny/klabis-be:latest - ./gradlew bootBuildImage --imageName=ghcr.io/zabiny/klabis-be:$(git rev-parse --short HEAD) + docker tag ghcr.io/zabiny/klabis-be:latest ghcr.io/zabiny/klabis-be:$(git rev-parse --short HEAD) + docker push -a ghcr.io/zabiny/klabis-be - name: Verify image run: docker images diff --git a/backend/build.gradle.kts b/backend/build.gradle.kts index 4b3ae7f..fc296f6 100644 --- a/backend/build.gradle.kts +++ b/backend/build.gradle.kts @@ -24,11 +24,6 @@ version = "0.1-SNAPSHOT" description = "klabis" java.sourceCompatibility = JavaVersion.VERSION_21 - -//val dockerImageName = "registry.polach.cloud/zbm/web-2.0/${group}.${description}:${project.version}" -val dockerImageName = "registry.polach.cloud/zbm/web-2.0/${description}:${project.version}" -println(dockerImageName) - val recordbuilderVersion = "41" val mapstructVersion = "1.6.0.Beta1" val mapstructSpringExtensionsVersion = "1.1.1" @@ -146,13 +141,13 @@ openApiGenerate { tasks.compileJava.get().dependsOn(tasks.openApiGenerate) tasks.getByName("bootBuildImage") { - imageName = "ghcr.io/${System.getenv("GITHUB_REPOSITORY")}:" + version - publish = StringUtils.isNotBlank(System.getenv("GITHUB_TOKEN")) + imageName = "${project.name}:${project.version}" + publish = false docker { publishRegistry { - username = StringUtils.defaultIfBlank(System.getenv("GITHUB_ACTOR"), "dummy") - password = StringUtils.defaultIfBlank(System.getenv("GITHUB_TOKEN"), "dummy") - url = "https://ghcr.io" + username = StringUtils.defaultIfBlank(System.getenv("DOCKER_REGISTRY_USERNAME"), "dummy") + password = StringUtils.defaultIfBlank(System.getenv("DOCKER_REGISTRY_PASSWORD"), "dummy") + url = System.getenv("DOCKER_REGISTRY_URL") email = "gradle@noreply.com" } }