From 6ae18fba369efc0e7be02f336e33e3820f1b626e Mon Sep 17 00:00:00 2001 From: Ben Sarmiento Date: Tue, 21 Nov 2023 10:52:52 +0100 Subject: [PATCH] Docker build changes --- .github/workflows/build_docker.yml | 28 +++++++++++++++++++++------- 1 file changed, 21 insertions(+), 7 deletions(-) diff --git a/.github/workflows/build_docker.yml b/.github/workflows/build_docker.yml index 1b4e1f6..a2cf44a 100644 --- a/.github/workflows/build_docker.yml +++ b/.github/workflows/build_docker.yml @@ -6,11 +6,6 @@ on: - main tags: - v0* - - latest - -env: - REGISTRY: ghcr.io - IMAGE_NAME: ${{ github.repository }}-testing jobs: build-and-push-image: @@ -37,7 +32,7 @@ jobs: - name: Log in to GitHub Container Registry uses: docker/login-action@v3 with: - registry: ${{ env.REGISTRY }} + registry: ghcr.io username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} @@ -45,7 +40,7 @@ jobs: id: meta uses: docker/metadata-action@v5 with: - images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + images: ghcr.io/${{ github.repository }} - name: Build and push Docker image uses: docker/build-push-action@v5 @@ -57,3 +52,22 @@ jobs: labels: ${{ steps.meta.outputs.labels }} cache-from: type=local,src=/tmp/.buildx-cache cache-to: type=local,dest=/tmp/.buildx-cache + + - name: Extract metadata (tags, labels) for Docker + if: startsWith(github.ref, 'refs/tags/v0') + id: publicmeta + uses: docker/metadata-action@v5 + with: + images: ghcr.io/${{ github.repository }}-testing + + - name: Build and push Docker image + if: startsWith(github.ref, 'refs/tags/v0') + uses: docker/build-push-action@v5 + with: + context: . + platforms: linux/amd64,linux/arm64 + push: true + tags: ${{ steps.publicmeta.outputs.tags }} + labels: ${{ steps.publicmeta.outputs.labels }} + cache-from: type=local,src=/tmp/.buildx-cache + cache-to: type=local,dest=/tmp/.buildx-cache