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