Skip to content

Commit

Permalink
ci: update merge-and-push job in axosyslog-docker workflow
Browse files Browse the repository at this point in the history
- after this change next docker tag will automatically
calculated in a following way:
  - if actual git tag version is greater than previous docker tag
    example:
       current git tag: 4.10.0
       last docker tag: 4.9.0-2
       next docker tag: 4.10.0-1
  - if actual git tag version is equals with previous docker tag
    example:
       current git tag: 4.9.0
       last docker tag: 4.9.0-2
       next docker tag: 4.9.0-3
  - if actual git tag version is less than previous docker tag, than
    compare script will display a warning and will exit

Signed-off-by: Andras Mitzki <[email protected]>
  • Loading branch information
Andras Mitzki committed Jan 14, 2025
1 parent b4aca29 commit 4391192
Showing 1 changed file with 26 additions and 5 deletions.
31 changes: 26 additions & 5 deletions .github/workflows/axosyslog-docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,8 @@ jobs:
merge-and-push:
runs-on: ubuntu-latest
needs: [prepare, image-build]
outputs:
tags: ${{ steps.docker-metadata-tags.outputs.tags }}
steps:
- name: Download digests
uses: actions/download-artifact@v4
Expand All @@ -151,11 +153,30 @@ jobs:

- name: Extract metadata (AxoSyslog version) for Docker
id: docker-metadata-tags
uses: docker/metadata-action@v5
with:
images: ${{ needs.prepare.outputs.image-name }}
tags: type=match,pattern=axosyslog-([0-9].*),group=1
sep-tags: ','
run: |
previous_docker_tag=$(skopeo inspect docker://ghcr.io/axoflow/axosyslog:latest | jq '.RepoTags' | sed 's/ \|"\|,//g' | grep "^[0-9]*.[0-9]*.[0-9]*$\|^[0-9]*.[0-9]*.[0-9]*-[0-9]*$" | tail -n 1)
previous_docker_tag_short=$(echo $previous_docker_tag | cut -d"-" -f1)
previous_docker_tag_patch=$(echo $previous_docker_tag | cut -d"-" -f2)
current_git_tag=$(echo ${{ github.ref }} | cut -d"-" -f2)
function version { echo "$@" | awk -F. '{ printf("%d%03d%03d\n", $1,$2,$3); }'; }
if [ $(version $current_git_tag) -gt $(version $previous_docker_tag_short) ]; then
echo "Given git tag version is greater than previous docker tag version: $current_git_tag > $previous_docker_tag_short"
next_docker_tag_with_patch=$current_git_tag-1
next_docker_tag=$current_git_tag
echo "Next docker version tag: $next_docker_tag_with_patch"
elif [ $(version $current_git_tag) -eq $(version $previous_docker_tag_short) ]; then
echo "Given git tag version is equals with previous docker tag version: $current_git_tag == $previous_docker_tag_short"
next_docker_tag_patch=$((previous_docker_tag_patch+1))
next_docker_tag_with_patch=$previous_docker_tag_short-$next_docker_tag_patch
next_docker_tag=$previous_docker_tag_short
echo "Next docker version tag: $next_docker_tag_with_patch"
else
echo "Given git tag version is less than previous docker tag version: $current_git_tag < $previous_docker_tag_short"
echo "This is not allowed. Please provide a valid git tag version."
exit 1
fi
TAGS="ghcr.io/axoflow/axosyslog:$next_docker_tag,ghcr.io/axoflow/axosyslog:$next_docker_tag_with_patch,ghcr.io/axoflow/axosyslog:latest"
echo "tags=$TAGS" >> $GITHUB_OUTPUT
- name: Compose Docker image tags
id: tags
Expand Down

0 comments on commit 4391192

Please sign in to comment.