Skip to content

Commit 65ab8bb

Browse files
committed
fix: use IMAGE_TAG_BASE and cache
1 parent 6362ab5 commit 65ab8bb

File tree

4 files changed

+15
-16
lines changed

4 files changed

+15
-16
lines changed

.github/workflows/main.yml

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# main.yml
22
name: Build and Release operator
3-
run-name: Build/Release operator triggerd by ${{ github.actor }} - ${{ github.event.head_commit.message }}${{ github.event.pull_request.title }}
3+
run-name: ${{ github.actor }} triggerd -> ${{ github.event.head_commit.message }}${{ github.event.pull_request.title }}
44

55
on:
66
push:
@@ -32,7 +32,7 @@ jobs:
3232
if: ${{ github.event_name == 'push' || github.event.pull_request.merged == true }}
3333
runs-on: ubuntu-latest
3434
outputs:
35-
IMAGE_REPO: ${{ steps.SET_IMAGE_REPO.outputs.IMAGE_REPO }}
35+
IMAGE_TAG_BASE: ${{ steps.SET_IMAGE_TAG_BASE.outputs.IMAGE_TAG_BASE }}
3636
OPERATOR_VERSION: ${{ steps.SET_OPERATOR_VERSION.outputs.OPERATOR_VERSION }}
3737
IS_RELEASE: ${{ steps.SET_OPERATOR_VERSION.outputs.IS_RELEASE }}
3838
current: ${{ steps.semver.outputs.current }}
@@ -43,9 +43,9 @@ jobs:
4343

4444
- name: Export Repo Name lowercase
4545
run: echo "REPO=${GITHUB_REPOSITORY,,}" >>${GITHUB_ENV}
46-
- name: Set IMAGE_REPO
47-
id: SET_IMAGE_REPO
48-
run: echo "IMAGE_REPO=${{ env.IMAGE_REGISTRY }}/${{ env.REPO }}" >>${GITHUB_OUTPUT}
46+
- name: Set IMAGE_TAG_BASE
47+
id: SET_IMAGE_TAG_BASE
48+
run: echo "IMAGE_TAG_BASE=${{ env.IMAGE_REGISTRY }}/${{ env.REPO }}" >>${GITHUB_OUTPUT}
4949

5050
- name: Get Next Version
5151
id: semver
@@ -91,7 +91,7 @@ jobs:
9191
docker:
9292
image: docker:dind
9393
env:
94-
IMAGE_REPO: ${{ needs.prepare.outputs.IMAGE_REPO }}
94+
IMAGE_TAG_BASE: ${{ needs.prepare.outputs.IMAGE_TAG_BASE }}
9595
OPERATOR_VERSION: ${{ needs.prepare.outputs.OPERATOR_VERSION }}
9696
steps:
9797
- name: Set up QEMU
@@ -111,7 +111,7 @@ jobs:
111111
platforms: linux/amd64,linux/arm64
112112
file: "Dockerfile.buildah.k8s.rootless"
113113
push: true
114-
tags: ${{ env.IMAGE_REPO }}-buildah:${{ env.OPERATOR_VERSION }}
114+
tags: ${{ env.IMAGE_TAG_BASE }}-buildah:${{ env.OPERATOR_VERSION }}
115115

116116
operator:
117117
needs: prepare
@@ -121,8 +121,10 @@ jobs:
121121
docker:
122122
image: docker:dind
123123
env:
124-
IMAGE_REPO: ${{ needs.prepare.outputs.IMAGE_REPO }}
125124
OPERATOR_VERSION: ${{ needs.prepare.outputs.OPERATOR_VERSION }}
125+
IMAGE_TAG_BASE: ${{ needs.prepare.outputs.IMAGE_TAG_BASE }}
126+
IMG: "${{ needs.prepare.outputs.IMAGE_TAG_BASE }}:${{ needs.prepare.outputs.OPERATOR_VERSION }}"
127+
BUNDLE_IMG: "${{ needs.prepare.outputs.IMAGE_TAG_BASE }}-bundle:${{ needs.prepare.outputs.OPERATOR_VERSION }}"
126128
steps:
127129
- name: Checkout code
128130
uses: actions/checkout@v3
@@ -147,11 +149,8 @@ jobs:
147149
PLATFORMS: linux/amd64,linux/arm64
148150
run: |
149151
echo "Building bundle"
150-
export IMG="${{ env.IMAGE_REPO }}:${{ env.OPERATOR_VERSION }}"
151-
export BUNDLE_IMG="${{ env.IMAGE_REPO }}-bundle:${{ env.OPERATOR_VERSION }}"
152152
make docker-buildx
153-
make bundle
154-
make bundle-buildx
153+
make bundle bundle-buildx
155154
156155
release:
157156
needs: [prepare, buildah, operator]

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ PLATFORMS ?= linux/arm64,linux/amd64,linux/s390x,linux/ppc64le
137137
docker-buildx: test create-buildx ## Build and push docker image for the manager for cross-platform support
138138
# copy existing Dockerfile and insert --platform=${BUILDPLATFORM} into Dockerfile.cross, and preserve the original Dockerfile
139139
sed -e '1 s/\(^FROM\)/FROM --platform=\$$\{BUILDPLATFORM\}/; t' -e ' 1,// s//FROM --platform=\$$\{BUILDPLATFORM\}/' Dockerfile > Dockerfile.cross
140-
- docker buildx build --push --platform=$(PLATFORMS) --tag ${IMG} -f Dockerfile.cross .
140+
- docker buildx build --push --platform=$(PLATFORMS) --tag ${IMG} --cache-to type=registry,ref=${IMAGE_TAG_BASE}:cache,oci-mediatypes=true,compression=zstd,mode=max --cache-from type=registry,ref=${IMAGE_TAG_BASE}:cache -f Dockerfile.cross .
141141
rm Dockerfile.cross
142142

143143
##@ Deployment
@@ -214,7 +214,7 @@ bundle-push: ## Push the bundle image.
214214
bundle-buildx: test create-buildx ## Build and push docker image for the manager for cross-platform support
215215
# copy existing Dockerfile and insert --platform=${BUILDPLATFORM} into Dockerfile.cross, and preserve the original Dockerfile
216216
sed -e '1 s/\(^FROM\)/FROM --platform=\$$\{BUILDPLATFORM\}/; t' -e ' 1,// s//FROM --platform=\$$\{BUILDPLATFORM\}/' bundle.Dockerfile > bundle.Dockerfile.cross
217-
- docker buildx build --push --platform=$(PLATFORMS) --tag ${BUNDLE_IMG} -f bundle.Dockerfile.cross .
217+
- docker buildx build --push --platform=$(PLATFORMS) --tag ${BUNDLE_IMG} --cache-to type=registry,ref=${IMAGE_TAG_BASE}-bundle:cache,oci-mediatypes=true,compression=zstd,mode=max --cache-from type=registry,ref=${IMAGE_TAG_BASE}-bundle:cache -f bundle.Dockerfile.cross .
218218
rm bundle.Dockerfile.cross
219219

220220
.PHONY: create-buildx

bundle.Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ LABEL operators.operatorframework.io.bundle.manifests.v1=manifests/
66
LABEL operators.operatorframework.io.bundle.metadata.v1=metadata/
77
LABEL operators.operatorframework.io.bundle.package.v1=execdat-operator
88
LABEL operators.operatorframework.io.bundle.channels.v1=alpha
9-
LABEL operators.operatorframework.io.metrics.builder=operator-sdk-v1.28.1
9+
LABEL operators.operatorframework.io.metrics.builder=operator-sdk-v1.29.0
1010
LABEL operators.operatorframework.io.metrics.mediatype.v1=metrics+v1
1111
LABEL operators.operatorframework.io.metrics.project_layout=go.kubebuilder.io/v4-alpha
1212

bundle/metadata/annotations.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ annotations:
55
operators.operatorframework.io.bundle.metadata.v1: metadata/
66
operators.operatorframework.io.bundle.package.v1: execdat-operator
77
operators.operatorframework.io.bundle.channels.v1: alpha
8-
operators.operatorframework.io.metrics.builder: operator-sdk-v1.28.1
8+
operators.operatorframework.io.metrics.builder: operator-sdk-v1.29.0
99
operators.operatorframework.io.metrics.mediatype.v1: metrics+v1
1010
operators.operatorframework.io.metrics.project_layout: go.kubebuilder.io/v4-alpha
1111

0 commit comments

Comments
 (0)