Skip to content

Commit fa438c0

Browse files
committed
ci(docker push): add docker tags based on release tags meta
1 parent f4610f1 commit fa438c0

File tree

1 file changed

+23
-7
lines changed

1 file changed

+23
-7
lines changed

.github/workflows/docker-push.yml

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,33 +3,49 @@ name: Docker Push
33
on:
44
push:
55
tags:
6-
- "v*.*.*"
6+
- 'v*.*.*'
77

88
jobs:
9-
109
build:
1110
runs-on: ubuntu-latest
1211
steps:
13-
- name: Check Out Repo
12+
- name: Check Out Repo
1413
uses: actions/checkout@v2
1514

1615
- name: Login to Docker Hub
1716
uses: docker/login-action@v1
1817
with:
1918
username: ${{ secrets.DOCKER_HUB_USERNAME }}
2019
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}
21-
20+
21+
- name: Get Docker meta
22+
id: meta
23+
uses: docker/metadata-action@v3
24+
with:
25+
# list of Docker images to use as base name for tags
26+
images: |
27+
${{ secrets.DOCKER_HUB_USERNAME }}/esamwad-user-service
28+
# generate Docker tags based on the following events/attributes
29+
tags: |
30+
type=schedule
31+
type=ref,event=branch
32+
type=ref,event=pr
33+
type=semver,pattern={{version}}
34+
type=semver,pattern={{major}}.{{minor}}
35+
type=semver,pattern={{major}}
36+
type=sha
37+
2238
- name: Set up Docker Buildx
2339
id: buildx
2440
uses: docker/setup-buildx-action@v1
25-
41+
2642
- name: Build and push
2743
id: docker_build
2844
uses: docker/build-push-action@v2
2945
with:
3046
context: .
3147
push: true
32-
tags: ${{ secrets.DOCKER_HUB_USERNAME }}/esamwad-user-service:latest
48+
tags: ${{ steps.meta.outputs.tags }}
3349

3450
- name: Image digest
35-
run: echo ${{ steps.docker_build.outputs.digest }}
51+
run: echo ${{ steps.docker_build.outputs.digest }}

0 commit comments

Comments
 (0)