From 6b5be6cb971f844b0038551131a1f15db518e9ff Mon Sep 17 00:00:00 2001 From: Assem Hasna Date: Wed, 13 Dec 2023 12:23:47 +0100 Subject: [PATCH 1/3] =?UTF-8?q?chore:=20update=20docker=20tags=20?= =?UTF-8?q?=F0=9F=90=B3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/_24_docker.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/_24_docker.yml b/.github/workflows/_24_docker.yml index f6d0833039..ab408309b8 100644 --- a/.github/workflows/_24_docker.yml +++ b/.github/workflows/_24_docker.yml @@ -98,7 +98,8 @@ jobs: type=raw,value=${{ github.sha }} type=raw,value=${{ inputs.network }} type=ref,event=branch - type=ref,event=tag + type=ref,event=branch,prefix=${{ inputs.network }}- + type=ref,event=tag,prefix=${{ inputs.network }}- type=ref,event=pr - name: Login to Github Container Registry 🔑 @@ -181,7 +182,8 @@ jobs: type=raw,value=${{ github.sha }} type=raw,value=${{ inputs.network }} type=ref,event=branch - type=ref,event=tag + type=ref,event=branch,prefix=${{ inputs.network }}- + type=ref,event=tag,prefix=${{ inputs.network }}- type=ref,event=pr - name: Login to DockerHub 🔑 From d642ec9c440769c1d09528fece9fee890b2a1cd2 Mon Sep 17 00:00:00 2001 From: Assem Hasna Date: Wed, 13 Dec 2023 12:54:31 +0100 Subject: [PATCH 2/3] chore: add version to network name --- .github/workflows/_24_docker.yml | 25 ++++++++++++++++++++----- ci/scripts/extract_version.sh | 20 +++++++++++++++----- 2 files changed, 35 insertions(+), 10 deletions(-) diff --git a/.github/workflows/_24_docker.yml b/.github/workflows/_24_docker.yml index ab408309b8..57b4aa18d5 100644 --- a/.github/workflows/_24_docker.yml +++ b/.github/workflows/_24_docker.yml @@ -38,7 +38,22 @@ jobs: run: | echo "date=$(date +'%Y-%m-%d')" >> "$GITHUB_OUTPUT" echo "time=$(date +'%H:%M:%S')" >> "$GITHUB_OUTPUT" - + get-version-from-branch-name: + runs-on: ubuntu-22.04 + outputs: + version: ${{ steps.version.outputs.version }} + steps: + - name: Checkout 🏁 + uses: actions/checkout@v3 + - name: Get version from branch name + id: version + run: | + version=$(./ci/scripts/extract_version.sh ${{ github.ref }}) + if [[ "$version" == "" ]]; then + echo "version=0.0.0" >> "$GITHUB_OUTPUT" + else + echo "version=$version" >> "$GITHUB_OUTPUT" + fi set-dockerfile-name: runs-on: ubuntu-22.04 outputs: @@ -54,7 +69,7 @@ jobs: fi private-images: - needs: [get-date-time, set-dockerfile-name] + needs: [get-date-time, set-dockerfile-name, get-version-from-branch-name] strategy: fail-fast: false matrix: @@ -98,8 +113,8 @@ jobs: type=raw,value=${{ github.sha }} type=raw,value=${{ inputs.network }} type=ref,event=branch - type=ref,event=branch,prefix=${{ inputs.network }}- type=ref,event=tag,prefix=${{ inputs.network }}- + type=raw,value=${{ needs.get-version-from-branch-name.outputs.version }}, prefix=${{ inputs.network }}-,enabled=${{ needs.get-version-from-branch-name.outputs.version != '0.0.0' }} type=ref,event=pr - name: Login to Github Container Registry 🔑 @@ -141,7 +156,7 @@ jobs: public-images: if: inputs.publish_public_images || inputs.save_tags != '' - needs: [get-date-time, set-dockerfile-name] + needs: [get-date-time, set-dockerfile-name, get-version-from-branch-name] strategy: fail-fast: false matrix: @@ -182,8 +197,8 @@ jobs: type=raw,value=${{ github.sha }} type=raw,value=${{ inputs.network }} type=ref,event=branch - type=ref,event=branch,prefix=${{ inputs.network }}- type=ref,event=tag,prefix=${{ inputs.network }}- + type=raw,value=${{ needs.get-version-from-branch-name.outputs.version }}, prefix=${{ inputs.network }}-,enabled=${{ needs.get-version-from-branch-name.outputs.version != '0.0.0' }} type=ref,event=pr - name: Login to DockerHub 🔑 diff --git a/ci/scripts/extract_version.sh b/ci/scripts/extract_version.sh index 52d7b966bc..ee45b2cd4e 100755 --- a/ci/scripts/extract_version.sh +++ b/ci/scripts/extract_version.sh @@ -1,10 +1,20 @@ #!/usr/bin/env bash -# Remove any prefixes like "v" from the tag -tag="${1#v}" +# Input string +input_string="$1" -# Extract major and minor version using cut command -version=$(echo "$tag" | cut -d. -f1,2) +# Regular expression to match version pattern (X.Y.Z or X.Y) +# This pattern looks for numbers separated by dots. +# The -E flag is used for extended regex, and -o to output only the matched part. +version=$(echo "$input_string" | grep -Eo '[0-9]+\.[0-9]+(\.[0-9]+)?') + +# Check if a version was found +if [[ -z "$version" ]]; then + exit 0 +fi + +# Extract major and minor version +major_minor=$(echo "$version" | cut -d. -f1,2) # Output the major and minor version -echo "$version" \ No newline at end of file +echo "$major_minor" From c22939da4d50a8b08b6cfe98eb1b7f498bc4f4cf Mon Sep 17 00:00:00 2001 From: Assem Hasna Date: Wed, 13 Dec 2023 13:17:11 +0100 Subject: [PATCH 3/3] fix: typo --- .github/workflows/_24_docker.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/_24_docker.yml b/.github/workflows/_24_docker.yml index 57b4aa18d5..4ebe84cf9f 100644 --- a/.github/workflows/_24_docker.yml +++ b/.github/workflows/_24_docker.yml @@ -49,6 +49,7 @@ jobs: id: version run: | version=$(./ci/scripts/extract_version.sh ${{ github.ref }}) + echo "Extracted version: $version" if [[ "$version" == "" ]]; then echo "version=0.0.0" >> "$GITHUB_OUTPUT" else @@ -114,7 +115,7 @@ jobs: type=raw,value=${{ inputs.network }} type=ref,event=branch type=ref,event=tag,prefix=${{ inputs.network }}- - type=raw,value=${{ needs.get-version-from-branch-name.outputs.version }}, prefix=${{ inputs.network }}-,enabled=${{ needs.get-version-from-branch-name.outputs.version != '0.0.0' }} + type=raw,value=${{ needs.get-version-from-branch-name.outputs.version }},prefix=${{ inputs.network }}-,enable=${{ needs.get-version-from-branch-name.outputs.version != '0.0.0' }} type=ref,event=pr - name: Login to Github Container Registry 🔑 @@ -198,7 +199,7 @@ jobs: type=raw,value=${{ inputs.network }} type=ref,event=branch type=ref,event=tag,prefix=${{ inputs.network }}- - type=raw,value=${{ needs.get-version-from-branch-name.outputs.version }}, prefix=${{ inputs.network }}-,enabled=${{ needs.get-version-from-branch-name.outputs.version != '0.0.0' }} + type=raw,value=${{ needs.get-version-from-branch-name.outputs.version }},prefix=${{ inputs.network }}-,enable=${{ needs.get-version-from-branch-name.outputs.version != '0.0.0' }} type=ref,event=pr - name: Login to DockerHub 🔑