Skip to content

Commit

Permalink
Another fix for the scheduled image build workflow for tag case (phot…
Browse files Browse the repository at this point in the history
…oview#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
  • Loading branch information
kkovaletp authored Dec 1, 2024
1 parent 6c020cc commit 8f989df
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
;;
*)
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 8f989df

Please sign in to comment.