Skip to content

Commit

Permalink
feat(): handle major and minor Docker images publishing
Browse files Browse the repository at this point in the history
  • Loading branch information
e7d committed Mar 28, 2024
1 parent 646a4c0 commit 5a342f7
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions .github/workflows/docker-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,18 @@ jobs:
cache-to: type=registry,ref=${{ vars.DOCKERHUB_IMAGE }}:buildcache,mode=max
push: true
tags: ${{ vars.DOCKERHUB_IMAGE }}:${{ github.sha }}
- name: Push "tag"
- name: Push semver tags
if: github.ref_type == 'tag'
run: |
GITHUB_REF=${{ github.ref }}
TAG=${GITHUB_REF#refs/tags/}
docker buildx imagetools create \
--tag ${{ vars.DOCKERHUB_IMAGE }}:${TAG} \
${{ vars.DOCKERHUB_IMAGE }}:${{ github.sha }}
- name: Push "latest"
TAGS="--tag ${{ vars.DOCKERHUB_IMAGE }}:${TAG}" # full version
if [ "${TAG}" != *-* ]; then # if not a pre-release
TAGS+=" --tag ${{ vars.DOCKERHUB_IMAGE }}:${TAG%%.*}" # major version
TAGS+=" --tag ${{ vars.DOCKERHUB_IMAGE }}:${TAG%.*}" # major.minor version
fi
docker buildx imagetools create ${TAG_STR} ${{ vars.DOCKERHUB_IMAGE }}:${{ github.sha }}
- name: Push "latest" tag
if: github.ref == 'refs/heads/main'
run: |
docker buildx imagetools create \
Expand Down

0 comments on commit 5a342f7

Please sign in to comment.