Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(docker): Add edge tag to Docker images, document when latest tag will appear #5312

Merged
merged 9 commits into from
Oct 6, 2022
12 changes: 10 additions & 2 deletions .github/workflows/build-docker-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ on:
description: 'The image digest to be used on a caller workflow'
value: ${{ jobs.build.outputs.image_digest }}

env:
USE_DOCKERHUB: ${{ github.event_name == 'release' && !github.event.release.prerelease }}

jobs:
build:
name: Build images
Expand Down Expand Up @@ -71,16 +74,21 @@ jobs:
# list of Docker images to use as base name for tags
images: |
us-docker.pkg.dev/zealous-zebra/zebra/${{ inputs.image_name }}
zfnd/zebra,enable=${{ github.event_name == 'release' && !github.event.release.prerelease }}
zfnd/zebra,enable=${{ env.USE_DOCKERHUB }}
# generate Docker tags based on the following events/attributes
tags: |
type=schedule
# semver and ref,tag automatically add a "latest" tag, but only on stable releases
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
type=ref,event=tag
type=ref,event=branch
type=ref,event=pr
type=sha
# edge is the latest commit on the default branch.
# We only have edge builds for `us-docker.pkg.dev`, because DockerHub doesn't keep up with every `main` branch commit.
type=edge,enable=${{ !env.USE_DOCKERHUB && is_default_branch }}
teor2345 marked this conversation as resolved.
Show resolved Hide resolved

# Setup Docker Buildx to allow use of docker cache layers from GH
- name: Set up Docker Buildx
Expand Down Expand Up @@ -110,7 +118,7 @@ jobs:
- name: Login to DockerHub
# We only publish images to DockerHub if a release is not a pre-release
# Ref: https://github.com/orgs/community/discussions/26281#discussioncomment-3251177
if: ${{ github.event_name == 'release' && !github.event.release.prerelease }}
if: ${{ env.USE_DOCKERHUB }}
uses: docker/login-action@v2.0.0
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
Expand Down