2525jobs :
2626 build :
2727 runs-on : ubuntu-latest
28+ strategy :
29+ matrix :
30+ image : [proxy, operator]
2831 steps :
2932 - name : Checkout
3033 uses : actions/checkout@v4
@@ -47,16 +50,31 @@ jobs:
4750 run : |
4851 RELEASE_VERSION=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)
4952 echo "release_version=${RELEASE_VERSION}" >> $GITHUB_OUTPUT
53+
54+ if [[ "${{matrix.image}}" == "operator" ]]; then
55+ CONTAINER_FILE="./Dockerfile.operator"
56+ elif [[ "${{matrix.image}}" == "proxy" ]]; then
57+ CONTAINER_FILE="./Dockerfile"
58+ else
59+ echo "Unknown matrix image: ${{matrix.image}}. Aborting build!"
60+ exit 1
61+ fi
62+ echo "container_file=${CONTAINER_FILE}" >> $GITHUB_OUTPUT
5063
5164 if [[ "${{ github.event_name }}" == "pull_request" || "${{ vars.REGISTRY_SERVER }}" == "" ]]; then
52- echo "proxy_tags=kroxylicious-proxy:${RELEASE_VERSION}" >> $GITHUB_OUTPUT
53- echo "operator_tags=kroxylicious-operator:${RELEASE_VERSION}" >> $GITHUB_OUTPUT
65+ echo "image_tags=${{ matrix.image }}:${RELEASE_VERSION}" >> $GITHUB_OUTPUT
5466 echo "push_images=false" >> $GITHUB_OUTPUT
5567 else
56- PROXY_IMAGE="${{ vars.REGISTRY_SERVER }}/${{ vars.REGISTRY_ORGANISATION }}/${{ vars.PROXY_IMAGE_NAME }}"
57- OPERATOR_IMAGE="${{ vars.REGISTRY_SERVER }}/${{ vars.REGISTRY_ORGANISATION }}/${{ vars.OPERATOR_IMAGE_NAME }}"
58- echo "proxy_tags=${PROXY_IMAGE}:${RELEASE_VERSION}" >> $GITHUB_OUTPUT
59- echo "operator_tags=${OPERATOR_IMAGE}:${RELEASE_VERSION},${OPERATOR_IMAGE}:latest" >> $GITHUB_OUTPUT
68+ if [[ "${{matrix.image}}" == "operator" ]]; then
69+ OPERATOR_IMAGE="${{ vars.REGISTRY_SERVER }}/${{ vars.REGISTRY_ORGANISATION }}/${{ vars.OPERATOR_IMAGE_NAME }}"
70+ echo "image_tags=${OPERATOR_IMAGE}:${RELEASE_VERSION},${OPERATOR_IMAGE}:latest" >> $GITHUB_OUTPUT
71+ elif [[ "${{matrix.image}}" == "proxy" ]]; then
72+ PROXY_IMAGE="${{ vars.REGISTRY_SERVER }}/${{ vars.REGISTRY_ORGANISATION }}/${{ vars.PROXY_IMAGE_NAME }}"
73+ echo "image_tags=${PROXY_IMAGE}:${RELEASE_VERSION}" >> $GITHUB_OUTPUT
74+ else
75+ echo "Unknown matrix image: ${{matrix.image}}. Aborting build!"
76+ exit 1
77+ fi
6078 echo "push_images=true" >> $GITHUB_OUTPUT
6179 fi
6280
@@ -68,27 +86,15 @@ jobs:
6886 username : ${{ vars.REGISTRY_USERNAME }}
6987 password : ${{ secrets.REGISTRY_TOKEN }}
7088
71- - name : Build and maybe push Proxy image
72- uses : docker/build-push-action@v6
73- with :
74- context : .
75- platforms : linux/amd64,linux/arm64
76- push : ${{ steps.build_configuration.outputs.push_images == 'true' }}
77- build-args : |
78- KROXYLICIOUS_VERSION=${{ steps.build_configuration.outputs.release_version }}
79- tags : ${{ steps.build_configuration.outputs.proxy_tags }}
80- cache-from : type=gha
81- cache-to : type=gha,mode=max,compression=zstd
82-
83- - name : Build and maybe push Operator image
89+ - name : Build and maybe push ${{matrix.image}} image
8490 uses : docker/build-push-action@v6
8591 with :
8692 context : .
87- file : ./Dockerfile.operator
93+ file : ${{ steps.build_configuration.outputs.container_file }}
8894 platforms : linux/amd64,linux/arm64
8995 push : ${{ steps.build_configuration.outputs.push_images == 'true' }}
9096 build-args : |
9197 KROXYLICIOUS_VERSION=${{ steps.build_configuration.outputs.release_version }}
92- tags : ${{ steps.build_configuration.outputs.operator_tags }}
98+ tags : ${{ steps.build_configuration.outputs.image_tags }}
9399 cache-from : type=gha
94100 cache-to : type=gha,mode=max,compression=zstd
0 commit comments