From 50b05be1837e5fcee9797977645025f48bef3047 Mon Sep 17 00:00:00 2001 From: BBQ Date: Fri, 20 Feb 2026 03:51:04 +0800 Subject: [PATCH] ci(docker): only push on tag, skip latest for prereleases - Remove push-to-main trigger; only tag push publishes images - Prerelease tags (e.g. v0.1.0-beta.2) publish their version tag only, without updating latest or short semver tags --- .github/workflows/docker-publish.yml | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml index 4be76c9b..b43a7776 100644 --- a/.github/workflows/docker-publish.yml +++ b/.github/workflows/docker-publish.yml @@ -2,7 +2,6 @@ name: Docker Publish on: push: - branches: [main] tags: ["v*.*.*"] pull_request: branches: [main] @@ -39,8 +38,7 @@ jobs: memohai/${{ matrix.image }} ghcr.io/${{ github.repository_owner }}/${{ matrix.image }} tags: | - type=raw,value=latest,enable={{is_default_branch}} - type=ref,event=branch + type=raw,value=latest,enable=${{ startsWith(github.ref, 'refs/tags/') && !contains(github.ref_name, '-') }} type=ref,event=pr type=semver,pattern={{version}} type=semver,pattern={{major}}.{{minor}} @@ -58,14 +56,14 @@ jobs: uses: docker/setup-buildx-action@v3 - name: Login to Docker Hub - if: github.event_name != 'pull_request' + if: startsWith(github.ref, 'refs/tags/') uses: docker/login-action@v3 with: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }} - name: Login to GitHub Container Registry - if: github.event_name != 'pull_request' + if: startsWith(github.ref, 'refs/tags/') uses: docker/login-action@v3 with: registry: ghcr.io @@ -77,7 +75,7 @@ jobs: with: context: . file: ${{ matrix.dockerfile }} - push: ${{ github.event_name != 'pull_request' }} + push: ${{ startsWith(github.ref, 'refs/tags/') }} tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} platforms: linux/amd64,linux/arm64