Python Kafka Client Container #8
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # | |
| # Licensed to the Apache Software Foundation (ASF) under one or more | |
| # contributor license agreements. See the NOTICE file distributed with | |
| # this work for additional information regarding copyright ownership. | |
| # The ASF licenses this file to You under the Apache License, Version 2.0 | |
| # (the "License"); you may not use this file except in compliance with | |
| # the License. You may obtain a copy of the License at | |
| # | |
| # http://www.apache.org/licenses/LICENSE-2.0 | |
| # | |
| # Unless required by applicable law or agreed to in writing, software | |
| # distributed under the License is distributed on an "AS IS" BASIS, | |
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
| # See the License for the specific language governing permissions and | |
| # limitations under the License. | |
| # | |
| # pythonkafkaclient.yaml - builds and pushes a Python Kafka Client container image. | |
| # | |
| # Requires repository variables: | |
| # - REGISTRY_SERVER - the server of the container registry service e.g. `quay.io` or `docker.io` | |
| # - REGISTRY_USERNAME - - your username on the service (or username of your robot account) | |
| # - REGISTRY_TOKEN - the access token that corresponds to `REGISTRY_USERNAME` | |
| # | |
| name: Python Kafka Client Container | |
| on: | |
| schedule: | |
| - cron: '0 0 * * 5' | |
| push: | |
| tags: [ '*.*.*' ] | |
| workflow_dispatch: | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| if: ${{ vars.REGISTRY_SERVER != '' && vars.REGISTRY_USERNAME != '' }} | |
| steps: | |
| - name: 'Get latest release version of confluent kafka python package' | |
| id: confluentKafkaPython | |
| uses: pozetroninc/[email protected] | |
| with: | |
| repository: confluentinc/confluent-kafka-python | |
| - name: 'Get latest release version of this repository' | |
| id: pythonKafkaClientRelease | |
| uses: pozetroninc/[email protected] | |
| with: | |
| repository: kroxylicious/python-kafka-test-client | |
| - name: 'Determine Version' | |
| id: confluentKafkaPythonVersion | |
| run: | | |
| REPO_RELEASE=${{ steps.confluentKafkaPython.outputs.release }} | |
| RELEASE=$(echo ${REPO_RELEASE//v}) | |
| echo "$RELEASE" | |
| echo "LIBRDKAFKA_VERSION=${RELEASE}" >> $GITHUB_ENV | |
| - name: 'Set release version from new tag' | |
| if: ${{ contains(github.ref, 'tag') }} | |
| run: | | |
| REPO_RELEASE=${{ github.ref_name }} | |
| echo "RELEASE_VERSION=${REPO_RELEASE}" >> $GITHUB_ENV | |
| - name: 'Set release version from latest tag' | |
| if: ${{ ! contains(github.ref, 'tag') }} | |
| run: | | |
| REPO_RELEASE=${{ steps.pythonKafkaClientRelease.outputs.release }} | |
| echo "RELEASE_VERSION=${REPO_RELEASE}" >> $GITHUB_ENV | |
| - name: 'Check out repository from latest tag' | |
| uses: actions/checkout@v5 | |
| with: | |
| ref: ${{ env.RELEASE_VERSION }} | |
| fetch-depth: 0 | |
| - name: 'Set up QEMU' | |
| uses: docker/setup-qemu-action@v3 | |
| - name: Set up Docker Buildx | |
| id: buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: 'Login to container registry' | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ${{ vars.REGISTRY_SERVER }} | |
| username: ${{ vars.REGISTRY_USERNAME }} | |
| password: ${{ secrets.REGISTRY_TOKEN }} | |
| - name: 'Build and push python kafka client container image' | |
| uses: docker/build-push-action@v6 | |
| with: | |
| context: . | |
| build-args: LIBRDKAFKA_VERSION=${{env.LIBRDKAFKA_VERSION}} | |
| platforms: linux/amd64,linux/arm64,linux/s390x,linux/ppc64le | |
| push: true | |
| tags: ${{ vars.REGISTRY_DESTINATION }}:${{ env.RELEASE_VERSION }}-${{ env.LIBRDKAFKA_VERSION }} | |
| cache-from: type=gha | |
| cache-to: type=gha,mode=max,compression=zstd |