Skip to content

Commit b8f47aa

Browse files
authored
ci: use docker/metadata-action
Current approach is not robust to more complex branch names. Related #4311 (comment). Pull-Request: #4421.
1 parent 92b5721 commit b8f47aa

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

.github/workflows/docker-image.yml

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,10 @@ name: Publish docker images
33
on:
44
push:
55
branches:
6-
- '**'
6+
- 'master'
77
tags:
88
- 'libp2p-server-**'
9+
pull_request:
910

1011
jobs:
1112
server:
@@ -22,14 +23,17 @@ jobs:
2223
- name: Set up Docker Buildx
2324
uses: docker/setup-buildx-action@v2
2425

25-
- name: Get branch or tag name
26-
id: ref-name
27-
run: echo ::set-output name=ref::${GITHUB_REF#refs/*/}
26+
- name: Docker meta
27+
id: meta
28+
uses: docker/metadata-action@v4
29+
with:
30+
images: ghcr.io/${{ github.repository }}-server
2831

2932
- name: Build and push
3033
uses: docker/build-push-action@v4
3134
with:
3235
context: .
3336
file: ./misc/server/Dockerfile
3437
push: true
35-
tags: ghcr.io/${{ github.repository }}-server:${{ steps.ref-name.outputs.ref }}
38+
tags: ${{ steps.meta.outputs.tags }}
39+
labels: ${{ steps.meta.outputs.labels }}

0 commit comments

Comments
 (0)