7878 uses : actions/setup-go@v5
7979 with :
8080 go-version : 1.23
81+ cache-dependency-path : operator/go.sum
8182 - name : Log in to the Container registry
8283 uses : docker/login-action@v3
8384 with :
9091 with :
9192 version : v0.26.0
9293 install_only : true
94+ - name : Restore cached Binaries
95+ id : cached-binaries
96+ uses : actions/cache/restore@v4
97+ with :
98+ key : ${{ runner.os }}-${{ runner.arch }}-bin-${{ hashFiles('operator/deps.mk') }}
99+ path : |
100+ ${{ github.workspace }}/operator/bin
101+ ~/.cache/go-build
102+ - name : Install dependencies
103+ if : steps.cached-binaries.outputs.cache-hit != 'true'
104+ run : |
105+ cd operator
106+ make install-deps
107+ - name : Save cached Binaries
108+ id : save-cached-binaries
109+ if : steps.cached-binaries.outputs.cache-hit != 'true'
110+ uses : actions/cache/save@v4
111+ with :
112+ key : ${{ runner.os }}-${{ runner.arch }}-bin-${{ hashFiles('operator/deps.mk') }}
113+ path : |
114+ ${{ github.workspace }}/operator/bin
115+ ~/.cache/go-build
93116 - name : end-to-end-tests
94117 run : |
95118 cd operator
@@ -131,11 +154,14 @@ jobs:
131154 apt-get update && apt-get install -y make git jq
132155 cd operator
133156 # if this is a tag build, use the tag as the version, otherwise use the sha
134- TAGS="-t ${REGISTRY@L}/${{env.IMAGE_NAME}}/operator:${{ github.sha }}"
157+ git fetch --all
158+ export GIT_SHA=$(git rev-parse --short ${{ github.sha }})
159+ TAGS="-t ${REGISTRY@L}/${{env.IMAGE_NAME}}/operator:${GIT_SHA}"
135160 case ${{ github.ref_type }} in
136161 branch)
137162 # The last tag + current git sha
138- export OPERATOR_VERSION=$(git describe --tags --abbrev=0 2>/dev/null || echo "0.0.0")+${{ github.sha }}
163+ export OPERATOR_VERSION=$(git tag --list 'operator*' --sort=-v:refname | head -n 1 | cut -d/ -f2 || echo "0.0.0")+${GIT_SHA}
164+ TAGS="$TAGS -t ${REGISTRY@L}/${{env.IMAGE_NAME}}/operator:$(echo "${OPERATOR_VERSION}" | tr + -)"
139165 ;;
140166 tag)
141167 # The version part of the tag
@@ -149,7 +175,7 @@ jobs:
149175 esac
150176 set -x
151177 docker buildx build \
152- --build-arg GIT_SHA=$${{ github.sha } } \
178+ --build-arg GIT_SHA=${GIT_SHA } \
153179 --build-arg VERSION=${OPERATOR_VERSION} \
154180 --build-arg GO_VERSION=${GO_VERSION} \
155181 --push \
0 commit comments