From 077d9ab90ce5abd78e2bfea68b6b74624c8dfa86 Mon Sep 17 00:00:00 2001 From: Hidetake Iwata Date: Sat, 28 Aug 2021 22:10:41 +0900 Subject: [PATCH] Use docker/metadata-action@v3 (#616) --- .github/docker-build-config.sh | 28 ---------------------------- .github/workflows/docker.yaml | 11 +++++++---- 2 files changed, 7 insertions(+), 32 deletions(-) delete mode 100755 .github/docker-build-config.sh diff --git a/.github/docker-build-config.sh b/.github/docker-build-config.sh deleted file mode 100755 index 1052f20..0000000 --- a/.github/docker-build-config.sh +++ /dev/null @@ -1,28 +0,0 @@ -#!/usr/bin/env bash -set -o pipefail -set -eux - -# only build on pull request -if [[ $GITHUB_EVENT_NAME == pull_request ]]; then - # e.g. refs/pulls/1/merge -> refs-pulls-1-merge - echo "::set-output name=tag::${GITHUB_REF//\//-}" - echo "::set-output name=push::false" - exit 0 -fi - -# push latest tag on master branch -if [[ $GITHUB_REF == refs/heads/master ]]; then - echo "::set-output name=tag::latest" - echo "::set-output name=push::true" - exit 0 -fi - -# push the corresponding tag on tag push -if [[ $GITHUB_REF == refs/tags/* ]]; then - echo "::set-output name=tag::${GITHUB_REF##*/}" - echo "::set-output name=push::true" - exit 0 -fi - -: unknown trigger -exit 1 diff --git a/.github/workflows/docker.yaml b/.github/workflows/docker.yaml index 1734f8e..3156045 100644 --- a/.github/workflows/docker.yaml +++ b/.github/workflows/docker.yaml @@ -27,8 +27,10 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - - run: .github/docker-build-config.sh - id: docker-build-config + - uses: docker/metadata-action@v3 + id: metadata + with: + images: ghcr.io/${{ github.repository }} - uses: docker/login-action@v1 with: registry: ghcr.io @@ -38,8 +40,9 @@ jobs: - uses: docker/setup-buildx-action@v1 - uses: docker/build-push-action@v2 with: - push: ${{ steps.docker-build-config.outputs.push }} - tags: ghcr.io/${{ github.repository }}:${{ steps.docker-build-config.outputs.tag }} + push: ${{ github.event_name == 'push' }} + tags: ${{ steps.metadata.outputs.tags }} + labels: ${{ steps.metadata.outputs.labels }} cache-from: type=registry,ref=ghcr.io/${{ github.repository }}:buildkit-cache cache-to: type=registry,ref=ghcr.io/${{ github.repository }}:buildkit-cache,mode=max platforms: linux/amd64,linux/arm64