|
| 1 | +# |
| 2 | +# Licensed to the Apache Software Foundation (ASF) under one or more |
| 3 | +# contributor license agreements. See the NOTICE file distributed with |
| 4 | +# this work for additional information regarding copyright ownership. |
| 5 | +# The ASF licenses this file to You under the Apache License, Version 2.0 |
| 6 | +# (the "License"); you may not use this file except in compliance with |
| 7 | +# the License. You may obtain a copy of the License at |
| 8 | +# |
| 9 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | +# |
| 11 | +# Unless required by applicable law or agreed to in writing, software |
| 12 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | +# See the License for the specific language governing permissions and |
| 15 | +# limitations under the License. |
| 16 | +# |
| 17 | +# pythonkafkaclient.yaml - builds and pushes a Python Kafka Client container image. |
| 18 | +# |
| 19 | +# Requires repository variables: |
| 20 | +# - REGISTRY_SERVER - the server of the container registry service e.g. `quay.io` or `docker.io` |
| 21 | +# - REGISTRY_USERNAME - - your username on the service (or username of your robot account) |
| 22 | +# - REGISTRY_TOKEN - the access token that corresponds to `REGISTRY_USERNAME` |
| 23 | +# |
| 24 | + |
| 25 | +name: Cron Scheduled Python Kafka Client Container |
| 26 | +on: |
| 27 | + schedule: |
| 28 | + - cron: '0 0 * * 5' |
| 29 | + workflow_dispatch: |
| 30 | +jobs: |
| 31 | + build: |
| 32 | + runs-on: ubuntu-latest |
| 33 | + if: ${{ vars.REGISTRY_SERVER != '' && vars.REGISTRY_USERNAME != '' }} |
| 34 | + steps: |
| 35 | + - name: 'Get latest release version of confluent kafka python package' |
| 36 | + id: confluentKafkaPython |
| 37 | + uses: pozetroninc/[email protected] |
| 38 | + with: |
| 39 | + repository: confluentinc/confluent-kafka-python |
| 40 | + excludes: prerelease, draft |
| 41 | + - name: 'Get latest release version of this repository' |
| 42 | + id: pythonKafkaClientRelease |
| 43 | + uses: pozetroninc/[email protected] |
| 44 | + with: |
| 45 | + repository: kroxylicious/python-kafka-test-client |
| 46 | + - name: 'Determine Version' |
| 47 | + id: confluentKafkaPythonVersion |
| 48 | + run: | |
| 49 | + REPO_RELEASE=${{ steps.confluentKafkaPython.outputs.release }} |
| 50 | + RELEASE=$(echo ${REPO_RELEASE//v}) |
| 51 | + echo "$RELEASE" |
| 52 | + echo "LIBRDKAFKA_VERSION=${RELEASE}" >> $GITHUB_ENV |
| 53 | + - name: 'Set release version from new tag' |
| 54 | + if: ${{ contains(github.ref, 'tag') }} |
| 55 | + run: | |
| 56 | + REPO_RELEASE=${{ github.ref_name }} |
| 57 | + echo "RELEASE_VERSION=${REPO_RELEASE}" >> $GITHUB_ENV |
| 58 | + - name: 'Set release version from latest tag' |
| 59 | + if: ${{ ! contains(github.ref, 'tag') }} |
| 60 | + run: | |
| 61 | + REPO_RELEASE=${{ steps.pythonKafkaClientRelease.outputs.release }} |
| 62 | + echo "RELEASE_VERSION=${REPO_RELEASE}" >> $GITHUB_ENV |
| 63 | + - name: 'Check out repository from latest tag' |
| 64 | + uses: actions/checkout@v6 |
| 65 | + with: |
| 66 | + ref: ${{ env.RELEASE_VERSION }} |
| 67 | + fetch-depth: 0 |
| 68 | + - name: 'Set up QEMU' |
| 69 | + uses: docker/setup-qemu-action@v3 |
| 70 | + - name: Set up Docker Buildx |
| 71 | + id: buildx |
| 72 | + uses: docker/setup-buildx-action@v3 |
| 73 | + - name: 'Login to container registry' |
| 74 | + uses: docker/login-action@v3 |
| 75 | + with: |
| 76 | + registry: ${{ vars.REGISTRY_SERVER }} |
| 77 | + username: ${{ vars.REGISTRY_USERNAME }} |
| 78 | + password: ${{ secrets.REGISTRY_TOKEN }} |
| 79 | + - name: 'Build and push python kafka client container image' |
| 80 | + uses: docker/build-push-action@v6 |
| 81 | + with: |
| 82 | + context: . |
| 83 | + build-args: LIBRDKAFKA_VERSION=${{env.LIBRDKAFKA_VERSION}} |
| 84 | + platforms: linux/amd64,linux/arm64,linux/s390x,linux/ppc64le |
| 85 | + push: true |
| 86 | + tags: ${{ vars.REGISTRY_DESTINATION }}:${{ env.RELEASE_VERSION }}-${{ env.LIBRDKAFKA_VERSION }} |
| 87 | + cache-from: type=gha |
| 88 | + cache-to: type=gha,mode=max,compression=zstd |
0 commit comments