From 8f989df30a85635f1de19278d92b3ce3f192dc4d Mon Sep 17 00:00:00 2001 From: Kostiantyn <32730812+kkovaletp@users.noreply.github.com> Date: Sun, 1 Dec 2024 18:55:53 +0200 Subject: [PATCH] Another fix for the scheduled image build workflow for tag case (#1137) * Try to fix the incorrect tag processing * more debug code * try with context=git * hopefully, final debug * the final commit with no debug code --------- Co-authored-by: Konstantin Koval --- .github/workflows/build.yml | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index df480ad33..7f4a5a62b 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -50,7 +50,7 @@ jobs: if [ -z "$TAG" ]; then echo 'tags=[{"tag": "${{ github.ref_name }}", "ref": "${{ github.ref }}"}]' | tee -a $GITHUB_OUTPUT else - echo tags=[{'"'tag'"': '"'${{ github.ref_name }}'"', '"'ref'"': '"'${{ github.ref }}'"'}, {'"'tag'"': '"'$TAG'"', '"'ref'"': '"'$(git show-ref --tags -d | grep "/$TAG$" | cut -d ' ' -f 2)'"'}] | tee -a $GITHUB_OUTPUT + echo tags=[{'"'tag'"': '"'${{ github.ref_name }}'"', '"'ref'"': '"'${{ github.ref }}'"'}, {'"'tag'"': '"'${TAG#v}'"', '"'ref'"': '"'$(git show-ref --tags -d | grep "/$TAG$" | cut -d ' ' -f 2)'"'}] | tee -a $GITHUB_OUTPUT fi ;; *) @@ -102,17 +102,20 @@ jobs: id: docker_meta uses: docker/metadata-action@v5 with: - # list of Docker images to use as base name for tags + context: "git" images: ${{ env.DOCKER_REGISTRY }}${{ env.DOCKER_IMAGE }} - # Docker tags based on the following events/attributes tags: | - type=schedule - type=ref,event=branch - type=ref,event=pr - type=semver,pattern={{version}} - type=semver,pattern={{major}}.{{minor}} - type=semver,pattern={{major}} - type=sha + ${{ github.event_name == 'schedule' && matrix.tags.tag != 'master' && 'type=semver,pattern={{version}}' || '' }} + ${{ github.event_name == 'schedule' && matrix.tags.tag != 'master' && 'type=semver,pattern={{major}}.{{minor}}' || '' }} + ${{ github.event_name == 'schedule' && matrix.tags.tag != 'master' && 'type=semver,pattern={{major}}' || '' }} + ${{ github.event_name == 'schedule' && matrix.tags.tag == 'master' && 'type=ref,event=branch' || '' }} + ${{ github.event_name == 'schedule' && matrix.tags.tag == 'master' && 'type=sha' || '' }} + ${{ github.event_name != 'schedule' && 'type=ref,event=branch' || '' }} + ${{ github.event_name != 'schedule' && 'type=ref,event=pr' || '' }} + ${{ github.event_name != 'schedule' && 'type=semver,pattern={{version}}' || '' }} + ${{ github.event_name != 'schedule' && 'type=semver,pattern={{major}}.{{minor}}' || '' }} + ${{ github.event_name != 'schedule' && 'type=semver,pattern={{major}}' || '' }} + ${{ github.event_name != 'schedule' && 'type=sha' || '' }} - name: Build and push uses: docker/build-push-action@v6