Skip to content

Commit

Permalink
chore: Update Docker image tag generation for GitHub Container Registry
Browse files Browse the repository at this point in the history
  • Loading branch information
Utesgui committed Jul 19, 2024
1 parent d44d16d commit c511f01
Showing 1 changed file with 21 additions and 7 deletions.
28 changes: 21 additions & 7 deletions .github/workflows/docker-publish-ghcr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,19 @@ jobs:
uses: docker/metadata-action@96383f45573cb7f253c731d3b3ab81c87ef81934 # v5.0.0
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
# Parse Github API output and search for tags only matching the current commit SHA
- name: set tag latest
id: tag-static
run: echo ::set-output name=tags::"latest"

# Merge the tag lists from docker/metadata-action and GitHub API
- name: Build tag list
id: tag-list
run: |
echo ::set-output name=tags::"$(
echo -n "${{ steps.meta.outputs.tags }}" | tr '\n' ','
for r in `echo "${{ steps.tag-static.outputs.tags }}" | tr '\n' ' '`; do echo -n ,${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:$r | tr '[:upper:]' '[:lower:]'; done
)"
# Build and push Docker image with Buildx (don't push on PR)
Expand All @@ -79,7 +92,8 @@ jobs:
with:
context: .
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
# tags: ${{ steps.meta.outputs.tags }}
tags: ${{ steps.tag-list.outputs.tags }}
# tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
Expand All @@ -100,10 +114,10 @@ jobs:
# against the sigstore community Fulcio instance.
run: echo "${TAGS}" | xargs -I {} cosign sign --yes {}@${DIGEST}

# Keep latest Tag up to date
- name: Update latest image
uses: silverlyra/[email protected]
with:
repository: ${{ github.repository }}
candidate-tag: ${{ github.ref_name }}
# # Keep latest Tag up to date
# - name: Update latest image
# uses: silverlyra/[email protected]
# with:
# repository: ${{ github.repository }}
# candidate-tag: ${{ github.ref_name }}

0 comments on commit c511f01

Please sign in to comment.