From 3663b7353358a25bcb4ab5ba733f90980f53a2f7 Mon Sep 17 00:00:00 2001 From: Aviel Segev Date: Wed, 1 Jan 2025 12:29:25 +0200 Subject: [PATCH] bug-fix: add another tag for containers when pushing to quay with the latest commit sha Signed-off-by: Aviel Segev --- .github/workflows/build-push-images.yml | 4 ++-- Makefile | 6 +++++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build-push-images.yml b/.github/workflows/build-push-images.yml index 3f45dca..8b8bf02 100644 --- a/.github/workflows/build-push-images.yml +++ b/.github/workflows/build-push-images.yml @@ -11,8 +11,8 @@ jobs: runs-on: ubuntu-latest env: REGISTRY: quay.io - # Set tag 'latest' on main branch - REGISTRY_TAG: ${{ (github.head_ref||github.ref_name)=='main' && 'latest' || (github.head_ref||github.ref_name) }} + # Set tag to the last commit sha on main branch, otherwise tag will be the branch name + REGISTRY_TAG: ${{ (github.head_ref||github.ref_name)=='main' && github.sha || (github.head_ref||github.ref_name) }} REGISTRY_ORG: kubev2v steps: - name: Checkout forklift diff --git a/Makefile b/Makefile index 499418d..9e784ee 100644 --- a/Makefile +++ b/Makefile @@ -12,6 +12,7 @@ MIGRATION_PLANNER_API_IMAGE_PULL_POLICY ?= Always MIGRATION_PLANNER_UI_IMAGE ?= quay.io/kubev2v/migration-planner-ui MIGRATION_PLANNER_NAMESPACE ?= assisted-migration INSECURE_REGISTRY ?= true +REGISTRY_TAG ?= latest DOWNLOAD_RHCOS ?= true KUBECTL ?= kubectl IFACE ?= eth0 @@ -91,13 +92,14 @@ build-api: bin build-agent: bin go build -buildvcs=false $(GO_BUILD_FLAGS) -o $(GOBIN) ./cmd/planner-agent ... - # rebuild container only on source changes bin/.migration-planner-agent-container: bin Containerfile.agent go.mod go.sum $(GO_FILES) $(PODMAN) build . --build-arg VERSION=$(SOURCE_GIT_TAG) -f Containerfile.agent -t $(MIGRATION_PLANNER_AGENT_IMAGE):latest + $(PODMAN) image tag $(MIGRATION_PLANNER_AGENT_IMAGE):latest $(MIGRATION_PLANNER_AGENT_IMAGE):$(REGISTRY_TAG) bin/.migration-planner-api-container: bin Containerfile.api go.mod go.sum $(GO_FILES) $(PODMAN) build . -f Containerfile.api -t $(MIGRATION_PLANNER_API_IMAGE):latest + $(PODMAN) image tag $(MIGRATION_PLANNER_API_IMAGE):latest $(MIGRATION_PLANNER_API_IMAGE):$(REGISTRY_TAG) migration-planner-api-container: bin/.migration-planner-api-container migration-planner-agent-container: bin/.migration-planner-agent-container @@ -108,7 +110,9 @@ build-containers: migration-planner-api-container migration-planner-agent-contai push-containers: build-containers $(PODMAN) push $(MIGRATION_PLANNER_API_IMAGE):latest + $(PODMAN) push $(MIGRATION_PLANNER_API_IMAGE):$(REGISTRY_TAG) $(PODMAN) push $(MIGRATION_PLANNER_AGENT_IMAGE):latest + $(PODMAN) push $(MIGRATION_PLANNER_AGENT_IMAGE):$(REGISTRY_TAG) deploy-on-kind: sed "s|@MIGRATION_PLANNER_AGENT_IMAGE@|$(MIGRATION_PLANNER_AGENT_IMAGE)|g; \