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
This commit is contained in:
Kostiantyn
2024-12-01 18:55:53 +02:00
committed by GitHub
parent 6c020cc1f9
commit 8f989df30a

View File

@@ -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