Skip to content

Commit

Permalink
Merge pull request #2 from e7d/feat/main/github-actions
Browse files Browse the repository at this point in the history
Publish major (`image:x`) and minor (`image:x.y`) tags of the Docker images
  • Loading branch information
e7d authored Mar 28, 2024
2 parents 2f3a123 + 90f0563 commit a869aa3
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions .github/workflows/docker-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,19 @@ 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"
GITHUB_TAG=${GITHUB_REF#refs/tags/}
TAGS=""
if [ "${GITHUB_TAG}" != *-* ]; then # if not a pre-release
TAGS+=" --tag ${{ vars.DOCKERHUB_IMAGE }}:${GITHUB_TAG%%.*}" # major version tag (e.g. 1)
TAGS+=" --tag ${{ vars.DOCKERHUB_IMAGE }}:${GITHUB_TAG%.*}" # major.minor version tag (e.g. 1.2)
fi
TAGS+=" --tag ${{ vars.DOCKERHUB_IMAGE }}:${GITHUB_TAG}" # full version tag (e.g. 1.2.3-rc.4)
docker buildx imagetools create ${TAGS} ${{ 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 a869aa3

Please sign in to comment.