From dd48badf65d5661c962ab60bd861326c1a69a085 Mon Sep 17 00:00:00 2001 From: sebastiansirch Date: Fri, 9 Jul 2021 14:19:40 +0200 Subject: [PATCH] Update build_push_to_ecr.yaml (#2) --- .github/workflows/build_push_to_ecr.yaml | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/.github/workflows/build_push_to_ecr.yaml b/.github/workflows/build_push_to_ecr.yaml index e463070..eb06e74 100644 --- a/.github/workflows/build_push_to_ecr.yaml +++ b/.github/workflows/build_push_to_ecr.yaml @@ -9,9 +9,7 @@ jobs: - name: Checkout uses: actions/checkout@v2 - - - name: Set env - run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV + - name: Login to Public ECR uses: docker/login-action@v1 @@ -42,13 +40,25 @@ jobs: - name: Maven package run: mvn package -B + + - + name: Docker meta + id: meta + uses: docker/metadata-action@v3 + with: + images: public.ecr.aws/m4k8r3n4/k8s-demo-app + tags: | + type=ref,event=branch + type=ref,event=pr + type=semver,pattern={{version}} + type=semver,pattern={{major}}.{{minor}} + - name: Build and push Docker images uses: docker/build-push-action@v2.6.1 with: context: . platforms: linux/amd64 - push: true - tags: | - public.ecr.aws/m4k8r3n4/k8s-demo-app:latest - public.ecr.aws/m4k8r3n4/k8s-demo-app:$RELEASE_VERSION + push: ${{ github.event_name != 'pull_request' }} + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }}