Skip to content

Commit

Permalink
Backend CI cleanups and improvements (#248)
Browse files Browse the repository at this point in the history
* Publish image is turned off in default in gradle

* Debugging on branch

* GITHUB CI automatically declares GITHUB_ACTOR env property

* gradle bootBuildImage task cleanup

* don't build twice same thing

* Added missing parameter to docker push

* Added backend publish script to it's detect paths

* corrected docker push

* cleanup of unused env vars

* cleanup
  • Loading branch information
dapolach authored Sep 15, 2024
1 parent 4b1a5cd commit 1695964
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 14 deletions.
7 changes: 3 additions & 4 deletions .github/workflows/backend_publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ on:
- main
paths:
- 'backend/**'
- '.github/workflows/backend_publish.yml'
workflow_dispatch: # Manual trigger

jobs:
Expand Down Expand Up @@ -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
15 changes: 5 additions & 10 deletions backend/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -146,13 +141,13 @@ openApiGenerate {
tasks.compileJava.get().dependsOn(tasks.openApiGenerate)

tasks.getByName<BootBuildImage>("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"
}
}
Expand Down

0 comments on commit 1695964

Please sign in to comment.