Skip to content

Commit

Permalink
manifest
Browse files Browse the repository at this point in the history
  • Loading branch information
rafaelbreno committed Oct 4, 2024
1 parent 1a25014 commit a3b4efc
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 23 deletions.
14 changes: 2 additions & 12 deletions .github/workflows/image-push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,6 @@ jobs:
public-password: ${{ env.DOCKER_PASSWORD }}
push-to-prime: false

- name: Export digest
run: |
mkdir -p /tmp/digests
echo "${{ steps.build-amd64.outputs.DIGEST_SHA }}" > "/tmp/digests/${{ steps.build-amd64.outputs.DIGEST_SHA }}"
- name: Upload digest
uses: actions/upload-artifact@v4
with:
Expand Down Expand Up @@ -102,11 +97,6 @@ jobs:
public-password: ${{ env.DOCKER_PASSWORD }}
push-to-prime: false

- name: Export digest
run: |
mkdir -p /tmp/digests
echo "${{ steps.build-arm64.outputs.DIGEST_SHA }}" > "/tmp/digests/${{ steps.build-arm64.outputs.DIGEST_SHA }}"
- name: Upload digest
uses: actions/upload-artifact@v4
with:
Expand Down Expand Up @@ -149,8 +139,8 @@ jobs:
id: push-manifest
uses: rancher/ecm-distro-tools/actions/publish-image@master
env:
DOCKER_METADATA_OUTPUT_JSON: ${{ steps.docker_meta.outputs.json }}
REGISTRY_IMAGEL: ${{ env.REGISTRY_IMAGE }}
DOCKER_METADATA_OUTPUT_JSON: ${{ steps.meta.outputs.json }}
REGISTRY_IMAGE: ${{ env.REGISTRY_IMAGE }}
with:
image: hardened-calico
tag: ${{ github.event.release.tag_name }}
Expand Down
29 changes: 18 additions & 11 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -64,23 +64,30 @@ push-image:
--label $(META_LABELS) \
--push \
--iidfile /tmp/image.digest \
--metadata-file /tmp/metadata.json
.

@echo "DIGEST=$(shell cat /tmp/image.digest)" >> $(GITHUB_OUTPUT)
@echo "DIGEST_SHA=$(shell cat /tmp/image.digest | sed 's/^sha256://')" >> $(GITHUB_OUTPUT)
# Create directory for storing digests
@mkdir -p /tmp/digests

FULL_DIGEST := $(shell jq -r '.containerimage.digest' /tmp/metadata.json)
DIGEST_SHA := $(shell echo $(FULL_DIGEST) | sed 's/^sha256://')

@echo $(DIGEST_SHA) > "/tmp/digests/$(DIGEST_SHA)"


.PHONY: manifest-push
manifest-push:
@echo "Creating and pushing manifest list..."

# tag from Docker metadata JSON
$(eval TAGS := $(shell echo '$(DOCKER_METADATA_OUTPUT_JSON)' | jq -r '.tags | map("-t " + .) | join(" ")'))

# digest files and format them for docker buildx
$(eval DIGESTS := $(shell for file in *; do echo -n "$(REGISTRY_IMAGE)@sha256:$$file "; done))

docker buildx imagetools create $(TAGS) $(DIGESTS)
TAGS := $(shell echo '$(DOCKER_METADATA_OUTPUT_JSON)' | jq -r '.tags | map("-t " + .) | join(" ")')

IMAGE_DIGESTS := $(shell for digest_file in *; do \
echo -n "$(REGISTRY_IMAGE)@sha256:$$digest_file "; \
done)

@echo "Tags to be used: $(TAGS)"
@echo "Image digests: $(IMAGE_DIGESTS)"

docker buildx imagetools create $(TAGS) $(IMAGE_DIGESTS)

.PHONY: image-push
image-push:
Expand Down

0 comments on commit a3b4efc

Please sign in to comment.