From 0d048d24d38748fd31c354c8534f3a58584bf001 Mon Sep 17 00:00:00 2001 From: Dimitri Huisman Date: Fri, 17 Mar 2023 13:05:33 +0000 Subject: [PATCH] Fix build.hcl / CI.yml regarding labels The version label and versions passed to docs image were based on the tag. Now we first build the images with -build appended to the tag, we cannot use the tag as version label. A new env var is introduced to pass the version to the build.hcl file. This will be used to set the VERSION label in the image, and pass as build arguments to the docs image. --- .github/workflows/build_test_deploy.yml | 8 ++++++++ tests/build.hcl | 12 +++++++++--- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build_test_deploy.yml b/.github/workflows/build_test_deploy.yml index d804adb0..e3c2f920 100644 --- a/.github/workflows/build_test_deploy.yml +++ b/.github/workflows/build_test_deploy.yml @@ -142,6 +142,8 @@ jobs: DOCKER_ORG: ghcr.io/${{ steps.string.outputs.lowercase }} MAILU_VERSION: ${{ env.MAILU_VERSION }} PINNED_MAILU_VERSION: ${{ env.PINNED_MAILU_VERSION }} + LABEL_VERSION: ${{ env.MAILU_VERSION }} + PINNED_LABEL_VERSION: ${{ env.PINNED_MAILU_VERSION }} uses: docker/bake-action@v2 with: files: ${{env.HCL_FILE}} @@ -198,6 +200,8 @@ jobs: DOCKER_ORG: ghcr.io/${{ steps.string.outputs.lowercase }} MAILU_VERSION: ${{ env.MAILU_VERSION }} PINNED_MAILU_VERSION: ${{ env.PINNED_MAILU_VERSION }} + LABEL_VERSION: ${{ env.MAILU_VERSION }} + PINNED_LABEL_VERSION: ${{ env.PINNED_MAILU_VERSION }} uses: docker/bake-action@v2 with: files: ${{env.HCL_FILE}} @@ -260,6 +264,8 @@ jobs: DOCKER_ORG: ghcr.io/${{ steps.string.outputs.lowercase }} MAILU_VERSION: ${{ env.MAILU_VERSION }}-build PINNED_MAILU_VERSION: ${{ env.PINNED_MAILU_VERSION }}-build + LABEL_VERSION: ${{ env.MAILU_VERSION }} + PINNED_LABEL_VERSION: ${{ env.PINNED_MAILU_VERSION }} uses: docker/bake-action@v2 with: files: ${{env.HCL_FILE}} @@ -323,6 +329,8 @@ jobs: DOCKER_ORG: ghcr.io/${{ steps.string.outputs.lowercase }} MAILU_VERSION: ${{ env.MAILU_VERSION }}-build PINNED_MAILU_VERSION: ${{ env.PINNED_MAILU_VERSION }}-build + LABEL_VERSION: ${{ env.MAILU_VERSION }} + PINNED_LABEL_VERSION: ${{ env.PINNED_MAILU_VERSION }} uses: docker/bake-action@v2 with: files: ${{env.HCL_FILE}} diff --git a/tests/build.hcl b/tests/build.hcl index f5893b8c..e7c8387a 100644 --- a/tests/build.hcl +++ b/tests/build.hcl @@ -20,6 +20,12 @@ variable "PINNED_MAILU_VERSION" { variable "MAILU_VERSION" { default = "local" } +variable "LABEL_VERSION" { + default = "local" +} +variable "PINNED_LABEL_VERSION" { + default = "local" +} #----------------------------------------------------------------------------------------- # Grouping of targets to build. All these images are built when using: @@ -54,7 +60,7 @@ target "defaults" { platforms = [ "linux/amd64"] dockerfile = "Dockerfile" args = { - VERSION = "${PINNED_MAILU_VERSION}" + VERSION = "${PINNED_LABEL_VERSION}" } } @@ -99,8 +105,8 @@ target "docs" { context = "docs/" tags = tag("docs") args = { - version = "${MAILU_VERSION}" - pinned_version = "${PINNED_MAILU_VERSION}" + version = "${LABEL_VERSION}" + pinned_version = "${PINNED_LABEL_VERSION}" } }