From b8f47aa9887c44029ba3ccd60ee34181651fd0ab Mon Sep 17 00:00:00 2001 From: Max Inden Date: Tue, 12 Sep 2023 07:54:29 +0200 Subject: [PATCH] ci: use `docker/metadata-action` Current approach is not robust to more complex branch names. Related https://github.com/libp2p/rust-libp2p/pull/4311#discussion_r1303958188. Pull-Request: #4421. --- .github/workflows/docker-image.yml | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index 7bde2040e2d..cd9a3fc7c56 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -3,9 +3,10 @@ name: Publish docker images on: push: branches: - - '**' + - 'master' tags: - 'libp2p-server-**' + pull_request: jobs: server: @@ -22,9 +23,11 @@ jobs: - name: Set up Docker Buildx uses: docker/setup-buildx-action@v2 - - name: Get branch or tag name - id: ref-name - run: echo ::set-output name=ref::${GITHUB_REF#refs/*/} + - name: Docker meta + id: meta + uses: docker/metadata-action@v4 + with: + images: ghcr.io/${{ github.repository }}-server - name: Build and push uses: docker/build-push-action@v4 @@ -32,4 +35,5 @@ jobs: context: . file: ./misc/server/Dockerfile push: true - tags: ghcr.io/${{ github.repository }}-server:${{ steps.ref-name.outputs.ref }} + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }}