Skip to content

Commit

Permalink
🔄 synced local '.github/workflows/build_docker_on_release.yml' with r…
Browse files Browse the repository at this point in the history
…emote 'template_workflows/auto_release/build_docker_on_release.yml' (#252)

Co-authored-by: surchs <null>
  • Loading branch information
surchs committed Aug 13, 2024
1 parent d32f5a8 commit 9555ae6
Showing 1 changed file with 28 additions and 1 deletion.
29 changes: 28 additions & 1 deletion .github/workflows/build_docker_on_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,27 @@ jobs:
-
name: Checkout
uses: actions/checkout@v4
-
# The release event is a superset of the push tag event,
# so we expect two tags to be generated by docker/metadata-action
# based on the behaviour for the type=semver,pattern=... tag type:
# 1. a semver tag vX.Y.Z (from the release Git tag; this is what will be used as the image version in the generated label)
# 2. latest (as type=semver,pattern=... is part of the latest tag handling)
# References:
# - https://github.com/docker/metadata-action?tab=readme-ov-file#typesemver
# - https://github.com/docker/metadata-action?tab=readme-ov-file#latest-tag
# - https://github.com/docker/metadata-action/issues/103
# - https://github.com/docker/metadata-action/issues/168
name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
# TODO: Repos with this wf must have DOCKERHUB_REPO set in the repository variables
images: ${{ secrets.DOCKERHUB_USERNAME }}/${{ env.DOCKERHUB_REPO }}
# NOTE: This input is probably not necessary as the action should generate the appropriate tags
# based on the default type=ref,event=tag, but we define an explicit pattern here for clarity
tags: |
type=semver,pattern={{raw}}
-
name: Login to Docker Hub
uses: docker/login-action@v3
Expand All @@ -27,4 +48,10 @@ jobs:
context: .
file: ./Dockerfile
push: true
tags: ${{ secrets.DOCKERHUB_USERNAME }}/query_tool:latest, ${{ secrets.DOCKERHUB_USERNAME }}/query_tool:${{ github.event.release.tag_name }}
tags: ${{ steps.meta.outputs.tags }}
# Select a subset of labels to apply from https://github.com/opencontainers/image-spec/blob/main/annotations.md#pre-defined-annotation-keys,
# following https://github.com/docker/metadata-action/issues/303
labels: |
org.opencontainers.image.created=${{ fromJSON(steps.meta.outputs.json).labels['org.opencontainers.image.source'] }}
org.opencontainers.image.revision=${{ fromJSON(steps.meta.outputs.json).labels['org.opencontainers.image.revision'] }}
org.opencontainers.image.version=${{ fromJSON(steps.meta.outputs.json).labels['org.opencontainers.image.version'] }}

0 comments on commit 9555ae6

Please sign in to comment.