From 671e84bec94e0878ef125df557ea8705894af821 Mon Sep 17 00:00:00 2001 From: Geoff Bourne Date: Fri, 14 May 2021 17:48:17 -0500 Subject: [PATCH] ci: use docker/metadata-action --- .github/workflows/build-multiarch.yml | 41 +++++++++------------------ 1 file changed, 13 insertions(+), 28 deletions(-) diff --git a/.github/workflows/build-multiarch.yml b/.github/workflows/build-multiarch.yml index d810a02a..ba139c7b 100644 --- a/.github/workflows/build-multiarch.yml +++ b/.github/workflows/build-multiarch.yml @@ -22,25 +22,15 @@ jobs: - name: Checkout uses: actions/checkout@v2.3.4 - - name: Prepare - id: prep - run: | - DOCKER_IMAGE=itzg/minecraft-server - VERSION=edge - if [[ $GITHUB_REF == refs/tags/* ]]; then - VERSION=${GITHUB_REF#refs/tags/} - fi - if [[ $GITHUB_REF == refs/heads/* ]]; then - VERSION=${GITHUB_REF#refs/heads/} - if [[ $VERSION == master ]]; then - VERSION=latest - fi - fi - TAGS="${DOCKER_IMAGE}:${VERSION//\//-}" - echo ::set-output name=tags::${TAGS} - echo ::set-output name=cache_from::${TAGS} - echo ::set-output name=version::${VERSION//\//-} - echo ::set-output name=cache_version::${VERSION//\//-} + - name: Docker meta + id: meta + uses: docker/metadata-action@v3 + with: + images: | + itzg/minecraft-server + tags: | + type=ref,event=branch + type=ref,event=tag - name: Setup Docker Buildx uses: docker/setup-buildx-action@v1 @@ -49,9 +39,9 @@ jobs: uses: actions/cache@v2.1.5 with: path: /tmp/.buildx-cache - key: ${{ runner.os }}-buildx-${{ steps.prep.outputs.cache_version }}-${{ github.sha }} + key: ${{ runner.os }}-buildx-${{ steps.meta.outputs.version }}-${{ github.sha }} restore-keys: | - ${{ runner.os }}-buildx-${{ steps.prep.outputs.cache_version }}- + ${{ runner.os }}-buildx-${{ steps.meta.outputs.version }}- - name: Set up QEMU uses: docker/setup-qemu-action@v1.1.0 @@ -67,19 +57,14 @@ jobs: uses: docker/build-push-action@v2.4.0 with: context: . - file: ./Dockerfile platforms: linux/amd64,linux/arm/v7,linux/arm64 push: ${{ github.event_name != 'pull_request' }} - tags: ${{ steps.prep.outputs.tags }} + tags: ${{ steps.meta.outputs.tags }} # ensure latest base image is used pull: true cache-from: type=local,src=/tmp/.buildx-cache cache-to: type=local,dest=/tmp/.buildx-cache - labels: | - org.opencontainers.image.documentation=https://github.com/itzg/docker-minecraft-server - org.opencontainers.image.source=https://github.com/itzg/docker-minecraft-server - org.opencontainers.image.version=${{ steps.prep.outputs.version }} - org.opencontainers.image.revision=${{ github.sha }} + labels: ${{ steps.meta.outputs.labels }} - name: Image digest run: echo ${{ steps.docker_build.outputs.digest }}