From ab84f8bbe94a99d560a8048de88a0c04bcfa05ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Nussbaumer?= Date: Fri, 25 Oct 2024 10:07:09 +0200 Subject: [PATCH] build(trident): add custom tag to images MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Clément Nussbaumer --- .github/workflows/trident.yaml | 37 +++++++++++++++++++++++++++++-- trident-distrowith/makefile.patch | 17 +++++++++++--- 2 files changed, 49 insertions(+), 5 deletions(-) diff --git a/.github/workflows/trident.yaml b/.github/workflows/trident.yaml index fe32da2..89209b1 100644 --- a/.github/workflows/trident.yaml +++ b/.github/workflows/trident.yaml @@ -10,7 +10,7 @@ on: jobs: build: - # github.ref == 'refs/heads/main' && + # github.ref == 'refs/heads/main' && if: | !github.event.pull_request.head.repo.fork @@ -42,11 +42,44 @@ jobs: working-directory: trident-distrowith/trident env: BUILD_TYPE: stable - run: make images + run: | + export CUSTOM_IMAGE_TAG=pf-$(echo $GITHUB_REF_NAME | tr "/" "-") && \ + make images - name: List docker images run: docker image ls + - name: Export docker images as artifacts + run: | + mkdir -p /tmp/docker-images/ + docker image ls --format=json | \ + jq -s '[.[] | select(.Repository | test("ghcr.io/postfinance/trident.*"))] | unique_by(.ID) |.[] | .Repository + ":" + .Tag' | \ + xargs -I_ docker save _ -o /tmp/docker-images/_.tar + + - name: Upload docker images artifacts + uses: actions/upload-artifact@v4 + with: + name: custom-trident-images + path: /tmp/docker-images/*.tar + + publish: + runs-on: ubuntu-latest + needs: build + steps: + - name: Download artifact + uses: actions/download-artifact@v4 + with: + name: custom-trident-images + path: docker-images/ + + - name: Display structure of downloaded files + run: find . + + - name: Load image(s) + run: | + find docker-images/ -name "*.tar" -exec docker load --input {} \; + docker image ls + - name: Log in to ghcr.io registry run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u $ --password-stdin diff --git a/trident-distrowith/makefile.patch b/trident-distrowith/makefile.patch index 87dcfa0..9d5fb32 100644 --- a/trident-distrowith/makefile.patch +++ b/trident-distrowith/makefile.patch @@ -1,7 +1,7 @@ ---- Makefile.original 2024-10-24 20:45:15 -+++ Makefile 2024-10-24 20:45:37 +--- trident/Makefile.original 2024-10-25 09:11:22 ++++ trident/Makefile 2024-10-25 09:21:23 @@ -93,7 +93,7 @@ - + # Constants ALL_PLATFORMS = linux/amd64 linux/arm64 windows/amd64/ltsc2022 windows/amd64/ltsc2019 darwin/amd64 -DEFAULT_REGISTRY = docker.io/netapp @@ -9,3 +9,14 @@ TRIDENT_CONFIG_PKG = github.com/netapp/trident/config OPERATOR_CONFIG_PKG = github.com/netapp/trident/operator/config TRIDENT_KUBERNETES_PKG = github.com/netapp/trident/persistent_store/crd +@@ -120,8 +120,9 @@ + TRIDENT_VERSION := $(VERSION)-$(BUILD_TYPE).$(BUILD_TYPE_REV) + endif + ++CUSTOM_IMAGE_TAG ?= + # tag variables +-TRIDENT_TAG := $(REGISTRY)/$(TRIDENT_IMAGE):$(TRIDENT_VERSION) ++TRIDENT_TAG := $(REGISTRY)/$(TRIDENT_IMAGE)-$(TRIDENT_VERSION):$(CUSTOM_IMAGE_TAG) + OPERATOR_TAG := $(REGISTRY)/$(OPERATOR_IMAGE):$(TRIDENT_VERSION) + TRIDENT_IMAGE_REPO := $(REGISTRY)/$(TRIDENT_IMAGE): + DEFAULT_OPERATOR_TAG := $(DEFAULT_REGISTRY)/$(OPERATOR_IMAGE):$(VERSION)