Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 8 additions & 27 deletions .github/workflows/docker-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,7 @@ name: Docker

on:
workflow_dispatch:
schedule:
- cron: '31 1 * * *'
push:
branches: [ "master" ]
# Publish semver tags as releases.
tags: [ '*.*.*' ]
pull_request:
Expand Down Expand Up @@ -46,10 +43,10 @@ jobs:
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@f95db51fddba0c2d1ec667646a06c2ce06100226 # v3.0.0

# Login against a Docker registry except on PR
# Login against a Docker registry only when publishing a tag
# https://github.com/docker/login-action
- name: Log into registry ${{ env.REGISTRY }}
if: github.event_name != 'pull_request'
if: github.ref_type == 'tag'
uses: docker/login-action@343f7c4344506bcbf9b4de18042ae17996df046d # v3.0.0
with:
registry: ${{ env.REGISTRY }}
Expand All @@ -73,34 +70,18 @@ jobs:
uses: docker/build-push-action@0565240e2d4ab88bba5387d719585280857ece09 # v5.0.0
with:
context: .
push: ${{ github.event_name != 'pull_request' }}
push: ${{ github.ref_type == 'tag' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max

# Re-tag the latest release image as :latest so the GitHub Packages
# page always recommends :latest instead of :master
- name: Get latest release tag
id: latest-release
if: github.event_name != 'pull_request'
run: |
if [ "${{ github.ref_type }}" = "tag" ]; then
LATEST_TAG="${{ github.ref_name }}"
else
LATEST_TAG=$(gh release view --json tagName -q .tagName 2>/dev/null || true)
fi

if [ -n "$LATEST_TAG" ]; then
echo "tag=$LATEST_TAG" >> "$GITHUB_OUTPUT"
fi
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Tag latest release as :latest
if: github.event_name != 'pull_request' && steps.latest-release.outputs.tag != ''
# Re-tag the release image as :latest so the GitHub Packages
# page always recommends :latest
- name: Tag release as :latest
if: github.ref_type == 'tag'
run: |
IMAGE_LOWER=$(echo "${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}" | tr '[:upper:]' '[:lower:]')
docker buildx imagetools create \
"${IMAGE_LOWER}:${{ steps.latest-release.outputs.tag }}" \
"${IMAGE_LOWER}:${{ github.ref_name }}" \
--tag "${IMAGE_LOWER}:latest"
Loading