name: Build and publish multiarch on: push: branches: - master - java8-multiarch - java8-openj9 - java11* - java16* - java17* - test/** tags: - "[0-9]+.[0-9]+.[0-9]+" - "[0-9]+.[0-9]+.[0-9]+-java8-multiarch" - "[0-9]+.[0-9]+.[0-9]+-java8-openj9" - "[0-9]+.[0-9]+.[0-9]+-java11*" - "[0-9]+.[0-9]+.[0-9]+-java16*" paths-ignore: - "*.md" - "docs/**" - "examples/**" env: IMAGE_TO_TEST: itzg/minecraft-server:test-${{ github.repository_owner }}-${{ github.run_id }} jobs: build: if: github.repository == 'itzg/docker-minecraft-server' runs-on: ubuntu-20.04 steps: - name: Checkout uses: actions/checkout@v2.4.0 - name: Docker meta id: meta uses: docker/metadata-action@v3 with: images: | itzg/minecraft-server tags: | type=ref,event=branch type=ref,event=tag flavor: | latest=${{ github.event_name == 'push' && github.ref == 'refs/heads/master' }} - name: Setup Docker Buildx uses: docker/setup-buildx-action@v1 - name: Set up QEMU uses: docker/setup-qemu-action@v1.2.0 - name: Login to DockerHub uses: docker/login-action@v1 with: username: ${{ secrets.DOCKER_USER }} password: ${{ secrets.DOCKER_PASSWORD }} - name: Build for test uses: docker/build-push-action@v2.8.0 if: github.ref_name == 'master' || startsWith(github.ref_name, 'test/') with: context: . platforms: linux/amd64 tags: ${{ env.IMAGE_TO_TEST }} # ensure latest base image is used pull: true load: true push: false cache-from: type=gha # no cache-to to avoid cross-cache update from next build step - name: Run tests # It is assumed that image variants are merged from master and tested there if: github.ref_name == 'master' || startsWith(github.ref_name, 'test/') run: | tests/test.sh - name: Build and push id: docker_build uses: docker/build-push-action@v2.8.0 with: context: . platforms: linux/amd64,linux/arm/v7,linux/arm64 push: true tags: ${{ steps.meta.outputs.tags }} # ensure latest base image is used pull: true cache-from: type=gha cache-to: type=gha,mode=max labels: ${{ steps.meta.outputs.labels }} - name: Image digest run: echo ${{ steps.docker_build.outputs.digest }}