From b58b35100dd4bfbbb24a98cdd655e9f251d919de Mon Sep 17 00:00:00 2001 From: Antoine Aflalo Date: Thu, 7 Mar 2024 14:57:09 -0500 Subject: [PATCH] feat: add pushing to docker-hub --- .github/workflows/docker-publish.yml | 32 ++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml index 2cfcf06..97cf67f 100644 --- a/.github/workflows/docker-publish.yml +++ b/.github/workflows/docker-publish.yml @@ -24,6 +24,7 @@ env: IMAGE_NAME: ${{ github.repository }} DOCKER_REPO: ghcr.io/${{ github.repository }} DOCKER_REPO_DEV: ghcr.io/${{ github.repository }}-dev + IMAGE_DOCKER_HUB: belphemur/mailcatcher-exim-courrier jobs: build: @@ -139,3 +140,34 @@ jobs: BUILD_DATE=$(date -u +"%Y-%m-%dT%H:%M:%SZ") VCS_REF=$(git rev-parse --short HEAD) VERSION=${{ steps.version.outputs.version }} + + - name: Extract Docker Hub metadata + id: meta-hub + if: github.event_name != 'pull_request' + uses: docker/metadata-action@v5 + with: + images: ${{ env.IMAGE_DOCKER_HUB }} + tags: | + type=semver,pattern={{version}},value=${{ steps.version.outputs.version }} + - name: Log into registry Docker hub + if: github.event_name != 'pull_request' + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + - name: Build and push Docker image ${{ matrix.platform }} to Docker Hub + id: build-and-push + uses: docker/build-push-action@v5 + with: + context: . + file: ./Dockerfile + platforms: ${{ matrix.platform }} + push: ${{ github.event_name != 'pull_request' }} + tags: ${{ steps.meta-hub.outputs.tags }} + labels: ${{ steps.meta-hub.outputs.labels }} + cache-from: type=gha + cache-to: type=gha,mode=max + build-args: | + BUILD_DATE=$(date -u +"%Y-%m-%dT%H:%M:%SZ") + VCS_REF=$(git rev-parse --short HEAD) + VERSION=${{ steps.version.outputs.version }}