Skip to content

Commit dd48bad

Browse files
Update build_push_to_ecr.yaml (#2)
1 parent 8944944 commit dd48bad

File tree

1 file changed

+17
-7
lines changed

1 file changed

+17
-7
lines changed

.github/workflows/build_push_to_ecr.yaml

+17-7
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,7 @@ jobs:
99

1010
- name: Checkout
1111
uses: actions/checkout@v2
12-
13-
- name: Set env
14-
run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
12+
1513

1614
- name: Login to Public ECR
1715
uses: docker/login-action@v1
@@ -42,13 +40,25 @@ jobs:
4240
- name: Maven package
4341
run: mvn package -B
4442

43+
44+
-
45+
name: Docker meta
46+
id: meta
47+
uses: docker/metadata-action@v3
48+
with:
49+
images: public.ecr.aws/m4k8r3n4/k8s-demo-app
50+
tags: |
51+
type=ref,event=branch
52+
type=ref,event=pr
53+
type=semver,pattern={{version}}
54+
type=semver,pattern={{major}}.{{minor}}
55+
4556
- name: Build and push Docker images
4657
uses: docker/[email protected]
4758
with:
4859
context: .
4960
platforms: linux/amd64
50-
push: true
51-
tags: |
52-
public.ecr.aws/m4k8r3n4/k8s-demo-app:latest
53-
public.ecr.aws/m4k8r3n4/k8s-demo-app:$RELEASE_VERSION
61+
push: ${{ github.event_name != 'pull_request' }}
62+
tags: ${{ steps.meta.outputs.tags }}
63+
labels: ${{ steps.meta.outputs.labels }}
5464

0 commit comments

Comments
 (0)