From c5ee7fb098cc55631afa30aaadc62f9fd3659210 Mon Sep 17 00:00:00 2001 From: Dzejkop Date: Mon, 18 Dec 2023 13:24:12 +0100 Subject: [PATCH] Build for multiple platforms --- .github/workflows/build-image-and-publish.yml | 62 ++++++++++++------- 1 file changed, 41 insertions(+), 21 deletions(-) diff --git a/.github/workflows/build-image-and-publish.yml b/.github/workflows/build-image-and-publish.yml index e3191c3..647fe82 100644 --- a/.github/workflows/build-image-and-publish.yml +++ b/.github/workflows/build-image-and-publish.yml @@ -4,28 +4,48 @@ on: push: branches: [ main, dev ] +env: + REGISTRY: ghcr.io + IMAGE_NAME: ${{ github.repository }} + jobs: build-and-push: runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + platform: [linux/amd64, linux/arm64, linux/arm/v7] steps: - - name: Check Out Repo - uses: actions/checkout@v2 - - - name: Log in to Docker Hub - uses: docker/login-action@v1 - with: - username: ${{ secrets.DOCKERHUB_USERNAME }} - password: ${{ secrets.DOCKERHUB_TOKEN }} - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v3 - - - name: Build and push Docker image - uses: docker/build-push-action@v2 - with: - context: . - file: Dockerfile - push: true - tags: dzejkop/tx-sitter:latest - cache-from: type=gha - cache-to: type=gha,mode=max + - name: Check Out Repo + uses: actions/checkout@v2 + + - name: Log in to Registry + uses: docker/login-action@v1 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Extract metadata (tags, labels) for Docker + id: meta + uses: docker/metadata-action@v1 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Build and push + uses: docker/build-push-action@v2 + with: + context: . + file: Dockerfile + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + platforms: ${{ matrix.platform }} + cache-from: type=gha + cache-to: type=gha,mode=max