From 5ae5b060188b491f64be98b43281058581f9d847 Mon Sep 17 00:00:00 2001 From: Janith Petangoda <22471198+janithpet@users.noreply.github.com> Date: Wed, 15 Jun 2022 09:45:18 +0100 Subject: [PATCH] Improve docker CI: push `vX.Y` tag (without patch) to DockerHub (#2507) * Create a docker tag without patch version if git tag has 0 patch version. * Create Docker tag without patch number if git tag follows v.. Add minor changes on CI --- .github/workflows/publish-docker-images.yml | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/.github/workflows/publish-docker-images.yml b/.github/workflows/publish-docker-images.yml index b9ea50cb3..8d24c1123 100644 --- a/.github/workflows/publish-docker-images.yml +++ b/.github/workflows/publish-docker-images.yml @@ -27,6 +27,20 @@ jobs: username: ${{ secrets.DOCKER_USERNAME }} password: ${{ secrets.DOCKER_PASSWORD }} + - name: Check tag format + id: check-tag-format + run: | + # Escape submitted tag name + escaped_tag=$(printf "%q" ${{ github.ref_name }}) + + # Check if tag has format v.. and set output.match + # to create a vX.Y (without patch version) Docker tag + if [[ $escaped_tag =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then + echo ::set-output name=match::true + else + echo ::set-output name=match::false + fi + - name: Docker meta id: meta uses: docker/metadata-action@v3 @@ -37,6 +51,7 @@ jobs: flavor: latest=false tags: | type=ref,event=tag + type=semver,pattern=v{{major}}.{{minor}},enable=${{ steps.check-tag-format.outputs.match }} type=raw,value=latest,enable=${{ github.event_name == 'release' }} - name: Build and push