From 71b441e4009a5dc5f1e028aa9c81574573bf5740 Mon Sep 17 00:00:00 2001 From: WillB97 Date: Sun, 25 Aug 2024 15:13:09 +0100 Subject: [PATCH] Rework --- .github/workflows/docker-image.yml | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index a29eb11..0efed62 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -6,8 +6,10 @@ on: - ci workflow_dispatch: -jobs: +env: + IMAGE_NAME: willb97/pyapriltags +jobs: build-image: runs-on: ubuntu-latest steps: @@ -16,13 +18,26 @@ jobs: submodules: recursive fetch-depth: 0 fetch-tags: true - - name: Build the Docker image - run: docker build . --file Dockerfile -t pyapriltags:$(git describe --tags --always) + - name: Generate release version + id: release_version + run: | + echo "WHEEL_VERSION=$IMAGE_NAME:$(git describe --tags --always)" >> "$GITHUB_OUTPUT" - name: 'Login to GitHub Container Registry' uses: docker/login-action@v3 with: registry: ghcr.io username: ${{github.actor}} password: ${{secrets.GITHUB_TOKEN}} - - name: 'Push image to GitHub Container Registry' - run: docker push ghcr.io/willb97/pyapriltags:$(git describe --tags --always) + - name: Extract metadata (tags, labels) for Docker + id: meta + uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7 + with: + images: ghcr.io/${{ env.IMAGE_NAME }} + - name: Build and push Docker image + id: push + uses: docker/build-push-action@v6 + with: + context: . + push: true + tags: ${{ steps.release_version.outputs.WHEEL_VERSION }} + labels: ${{ steps.meta.outputs.labels }}