name: Build and Publish Docker Image on: push: branches: [main] tags: ['v*'] jobs: build-and-push: runs-on: ubuntu-latest strategy: fail-fast: false matrix: include: - dockerfile: ./docker/app.Dockerfile image: ghcr.io/simstudioai/simstudio - dockerfile: ./docker/db.Dockerfile image: ghcr.io/simstudioai/migrations - dockerfile: ./docker/realtime.Dockerfile image: ghcr.io/simstudioai/realtime permissions: contents: read packages: write steps: - name: Checkout repository uses: actions/checkout@v4 - name: Set up QEMU uses: docker/setup-qemu-action@v3 - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 - name: Log in to the Container registry if: github.event_name != 'pull_request' uses: docker/login-action@v3 with: registry: ghcr.io username: ${{ github.repository_owner }} password: ${{ secrets.GITHUB_TOKEN }} - name: Extract metadata (tags, labels) for Docker id: meta uses: docker/metadata-action@v5 with: images: ${{ matrix.image }} tags: | type=raw,value=latest,enable=${{ github.ref == 'refs/heads/main' }} type=ref,event=pr type=semver,pattern={{version}} type=semver,pattern={{major}}.{{minor}} type=semver,pattern={{major}}.{{minor}}.{{patch}} type=sha,format=long - name: Build and push Docker image uses: docker/build-push-action@v6 with: context: . file: ${{ matrix.dockerfile }} platforms: linux/amd64,linux/arm64 push: ${{ github.event_name != 'pull_request' }} tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} cache-from: type=gha cache-to: type=gha,mode=max