From 564fe68403f6aa1f0ffd61882ec41d4c40ade748 Mon Sep 17 00:00:00 2001 From: Alex Gaynor Date: Sun, 13 Oct 2024 10:08:57 -0400 Subject: [PATCH] Attempt to get the correct digest for the docker image --- .github/workflows/build-docker-images.yml | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/.github/workflows/build-docker-images.yml b/.github/workflows/build-docker-images.yml index 8811d445..622c6d1b 100644 --- a/.github/workflows/build-docker-images.yml +++ b/.github/workflows/build-docker-images.yml @@ -77,14 +77,19 @@ jobs: run: docker pull ghcr.io/pyca/${{ matrix.IMAGE.TAG_NAME }} || true if: github.event_name != 'schedule' && github.event_name != 'workflow_dispatch' - name: Build image - run: docker build --pull --cache-from ghcr.io/pyca/${{ matrix.IMAGE.TAG_NAME }} -t ghcr.io/pyca/${{ matrix.IMAGE.TAG_NAME }} ${{ matrix.IMAGE.DOCKERFILE_PATH }} ${{ matrix.IMAGE.BUILD_ARGS }} --build-arg "NODE_ARCH_RELEASE=${NODE_ARCH_RELEASE}" + run: | + docker build --pull --cache-from ghcr.io/pyca/${{ matrix.IMAGE.TAG_NAME }} \ + -t ghcr.io/pyca/${{ matrix.IMAGE.TAG_NAME }} \ + --metadata-file metadata.json \ + ${{ matrix.IMAGE.DOCKERFILE_PATH }} \ + ${{ matrix.IMAGE.BUILD_ARGS }} --build-arg "NODE_ARCH_RELEASE=${NODE_ARCH_RELEASE}" - name: Get image digest id: image-digest run: | - DIGEST=$(docker inspect --format="{{ .Id }}" "ghcr.io/pyca/${{ matrix.IMAGE.TAG_NAME }}") - echo "DIGEST=${DIGEST}" | tee -a "$GITHUB_OUTPUT" - IMAGE_NAME=$(echo "${{ matrix.IMAGE.TAG_NAME }}" | cut -d ':' -f 1) - echo "IMAGE_NAME=${IMAGE_NAME}" | tee -a "$GITHUB_OUTPUT" + DIGEST=$(jq -r '.["containerimage.digest"]' metadata.json) + echo "DIGEST=${DIGEST}" | tee -a "$GITHUB_OUTPUT" + IMAGE_NAME=$(echo "${{ matrix.IMAGE.TAG_NAME }}" | cut -d ':' -f 1) + echo "IMAGE_NAME=${IMAGE_NAME}" | tee -a "$GITHUB_OUTPUT" - name: Login to docker run: 'docker login -u "$DOCKER_USERNAME" -p "$DOCKER_PASSWORD" ghcr.io' env: