Repository navigation
Hotfix/kafka 3 #24
Workflow file for this run
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
| name: Publish Docker Images (dev) | |
| on: | |
| pull_request_target: | |
| types: [ closed ] | |
| branches: [ "dev" ] | |
| env: | |
| REGISTRY: ghcr.io | |
| jobs: | |
| bump-version: | |
| name: Bump VERSION file | |
| if: github.event.pull_request.merged == true | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write # needed to push the updated VERSION file back | |
| outputs: | |
| new_version: ${{ steps.bump.outputs.version }} | |
| version_changed: ${{ steps.bump.outputs.changed }} | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| with: | |
| token: ${{ secrets.PIPELINE_PAT }} | |
| ref: ${{ github.event.pull_request.base.ref }} | |
| fetch-depth: 0 | |
| - name: Detect source branch and bump version | |
| id: bump | |
| run: | | |
| SOURCE="${{ github.event.pull_request.head.ref }}" | |
| if [[ -z "$SOURCE" ]]; then | |
| SOURCE="unknown" | |
| echo "::warning::Could not detect source branch from pull request metadata; defaulting to 'unknown' (no bump)." | |
| fi | |
| echo "Detected source branch: ${SOURCE}" | |
| # ── Read and parse current VERSION ────────────────────────────────── | |
| RAW="$(cat VERSION | tr -d '[:space:]')" | |
| CLEAN="${RAW#v}" # strip leading v | |
| while [[ "$CLEAN" == *-dev ]]; do | |
| CLEAN="${CLEAN%-dev}" | |
| done | |
| if [[ ! "$CLEAN" =~ ^([0-9]+)\.([0-9]+)\.([0-9]+)$ ]]; then | |
| echo "::error::VERSION must be in the form v<major>.<minor>.<patch>[-dev], got '${RAW}'" | |
| exit 1 | |
| fi | |
| MAJOR="${BASH_REMATCH[1]}" | |
| MINOR="${BASH_REMATCH[2]}" | |
| PATCH="${BASH_REMATCH[3]}" | |
| # ── Apply bump based on branch prefix ──────────────────────────────── | |
| PREFIX="${SOURCE%%/*}" | |
| case "$PREFIX" in | |
| feature) | |
| MINOR=$(( MINOR + 1 )); PATCH=0 | |
| ;; | |
| bugfix|hotfix) | |
| PATCH=$(( PATCH + 1 )) | |
| ;; | |
| release) | |
| MAJOR=$(( MAJOR + 1 )); MINOR=0; PATCH=0 | |
| ;; | |
| *) | |
| # unknown / no recognisable prefix → no bump | |
| ;; | |
| esac | |
| # ── Compose new version with -dev suffix ───────────────────────────── | |
| NEW_VERSION="v${MAJOR}.${MINOR}.${PATCH}-dev" | |
| echo "${NEW_VERSION}" > VERSION | |
| echo "version=${NEW_VERSION}" >> "$GITHUB_OUTPUT" | |
| if [[ "$RAW" != "$NEW_VERSION" ]]; then | |
| echo "changed=true" >> "$GITHUB_OUTPUT" | |
| else | |
| echo "changed=false" >> "$GITHUB_OUTPUT" | |
| fi | |
| echo "New version: ${NEW_VERSION}" | |
| - name: Commit and push updated VERSION | |
| if: steps.bump.outputs.changed == 'true' | |
| run: | | |
| git config user.name "github-actions[bot]" | |
| git config user.email "github-actions[bot]@users.noreply.github.com" | |
| git add VERSION | |
| if git diff --cached --quiet; then | |
| echo "No VERSION changes to commit." | |
| exit 0 | |
| fi | |
| git commit -m "chore: bump version to ${{ steps.bump.outputs.version }} [skip ci]" | |
| git push | |
| build-and-push: | |
| name: Build & Push ${{ matrix.container }} | |
| if: github.event.pull_request.merged == true | |
| needs: bump-version | |
| runs-on: ubuntu-latest | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| container: | |
| - detector | |
| - inspector | |
| - logcollector | |
| - logserver | |
| - prefilter | |
| - monitoring | |
| - alerter | |
| permissions: | |
| contents: read | |
| packages: write | |
| id-token: write | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| with: | |
| ref: ${{ github.event.pull_request.base.ref }} | |
| - name: Setup Docker buildx | |
| uses: docker/setup-buildx-action@v4 | |
| - name: Log into registry ${{ env.REGISTRY }} | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ${{ env.REGISTRY }} | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Extract Docker metadata | |
| id: meta | |
| uses: docker/metadata-action@v5 | |
| with: | |
| images: ${{ env.REGISTRY }}/${{ github.repository }}-${{ matrix.container }} | |
| tags: | | |
| type=raw,value=${{ needs.bump-version.outputs.new_version }} | |
| type=raw,value=latest-dev | |
| - name: Build and push Docker image | |
| uses: docker/build-push-action@v6 | |
| with: | |
| context: . | |
| push: true | |
| tags: ${{ steps.meta.outputs.tags }} | |
| labels: ${{ steps.meta.outputs.labels }} | |
| file: ./docker/dockerfiles/Dockerfile.${{ matrix.container }} |