From cb64e60cb46c96cb6e8425d845d53cc3ac0dc3af Mon Sep 17 00:00:00 2001 From: galal-hussein Date: Thu, 6 Jun 2024 22:12:32 +0300 Subject: [PATCH] Fix passing the tag to build-args Signed-off-by: galal-hussein --- .github/workflows/build.yml | 4 ++++ .github/workflows/image-push.yml | 10 ++++++++++ Makefile | 8 ++++++-- 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index fd73f72..7e10cdb 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -27,6 +27,8 @@ jobs: push: false tags: rancher/hardened-whereabouts:${{ env.TAG }}-amd64 file: Dockerfile + build-args: | + TAG=${{ env.TAG }} - name: Run Trivy vulnerability scanner uses: aquasecurity/trivy-action@0.21.0 @@ -68,3 +70,5 @@ jobs: file: Dockerfile outputs: type=docker platforms: linux/arm64 + build-args: | + TAG=${{ env.TAG }} diff --git a/.github/workflows/image-push.yml b/.github/workflows/image-push.yml index 918a687..929c6ab 100644 --- a/.github/workflows/image-push.yml +++ b/.github/workflows/image-push.yml @@ -5,6 +5,9 @@ on: permissions: contents: read +env: + GITHUB_ACTION_TAG: ${{ github.ref_name }} + jobs: push-multiarch: permissions: @@ -15,6 +18,11 @@ jobs: - name: Check out code uses: actions/checkout@v4 + - name: Set the TAG value + id: get-TAG + run: | + echo "$(make -s log | grep TAG)" >> "$GITHUB_ENV" + - name: Set up QEMU uses: docker/setup-qemu-action@v3 @@ -42,3 +50,5 @@ jobs: tags: rancher/hardened-whereabouts:${{ github.event.release.tag_name }} file: Dockerfile platforms: linux/amd64, linux/arm64 + build-args: | + TAG=${{ env.TAG }} diff --git a/Makefile b/Makefile index 3a1d7d0..d17a57a 100644 --- a/Makefile +++ b/Makefile @@ -14,7 +14,11 @@ BUILD_META=-build$(shell date +%Y%m%d) ORG ?= rancher PKG ?= github.com/k8snetworkplumbingwg/whereabouts SRC ?= github.com/k8snetworkplumbingwg/whereabouts -TAG ?= v0.7.0$(BUILD_META) +TAG ?= ${GITHUB_ACTION_TAG} + +ifeq ($(TAG),) +TAG := v0.7.0$(BUILD_META) +endif ifeq (,$(filter %$(BUILD_META),$(TAG))) $(error TAG $(TAG) needs to end with build metadata: $(BUILD_META)) @@ -45,7 +49,7 @@ image-scan: PHONY: log log: @echo "ARCH=$(ARCH)" - @echo "TAG=$(TAG)" + @echo "TAG=$(TAG:$(BUILD_META)=)" @echo "ORG=$(ORG)" @echo "PKG=$(PKG)" @echo "SRC=$(SRC)"