From 4f50761be2122b9249f61c09ffaaedcae4b0034a Mon Sep 17 00:00:00 2001 From: Anders Sparrevohn Date: Tue, 23 Aug 2022 23:21:18 +0200 Subject: [PATCH] Improve docker image tagging --- .github/workflows/docker-image.yml | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index 572c4e8cf..d52ad80f0 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -1,10 +1,12 @@ name: Docker image CD on: - workflow_dispatch: push: tags: - '*.*.*' + pull_request: + branches: + - 'master' jobs: build_and_push: @@ -13,6 +15,16 @@ jobs: - name: Checkout code uses: actions/checkout@v3 + - name: Docker metadata + id: meta + uses: docker/metadata-action@v4 + with: + images: grobut939/ghostfolio + tags: | + type=ref,event=pr + type=semver,pattern={{version}} + type=semver,pattern={{major}}.{{minor}} + - name: Set up QEMU uses: docker/setup-qemu-action@v2 @@ -21,6 +33,7 @@ jobs: uses: docker/setup-buildx-action@v2 - name: Login to DockerHub + if: github.event_name != 'pull_request' uses: docker/login-action@v2 with: username: ${{ secrets.DOCKER_USERNAME }} @@ -31,7 +44,8 @@ jobs: with: context: . platforms: linux/amd64,linux/arm64 - push: true - tags: grobut939/ghostfolio:latest + push: ${{ github.event_name != 'pull_request' }} + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.output.labels }} cache-from: type=gha cache-to: type=gha,mode=max