Skip to content

Commit

Permalink
Add images to the manifest and push the manifest to registry
Browse files Browse the repository at this point in the history
  • Loading branch information
p5 committed Jul 10, 2024
1 parent 392ad50 commit fb0d72f
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 8 deletions.
24 changes: 24 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -83,3 +83,27 @@ jobs:
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
compression-formats: gzip zstd:chunked

- name: Inspect Image Manifest
env:
MANIFEST_TAG: ${{ github.sha }}-${{ github.run_number }}
REGISTRY: ghcr.io/${{ github.repository }}
IMAGE: sample-image
DIGEST: ${{ steps.push.outputs.digest }}
run: |
MANIFEST=$(skopeo inspect docker://${REGISTRY}/${IMAGE}:${MANIFEST_TAG} | jq .)
echo "Manifest: $MANIFEST"
if [[ $(echo $MANIFEST | jq -r .Digest) != $DIGEST ]]; then
echo "Digest mismatch - expected $DIGEST, got $(echo $MANIFEST | jq -r .Digest)"
exit 1
fi
- name: Inspect Image Raw Manifest
env:
MANIFEST_TAG: ${{ github.sha }}-${{ github.run_number }}
REGISTRY: ghcr.io/${{ github.repository }}
IMAGE: sample-image
DIGEST: ${{ steps.push.outputs.digest }}
run: |
RAW_MANIFEST=$(skopeo inspect --raw docker://${REGISTRY}/${IMAGE}:${MANIFEST_TAG} | jq -r .)
echo "Raw Manifest: $RAW_MANIFEST"
47 changes: 39 additions & 8 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -178,17 +178,48 @@ runs:
echo "MANIFEST_NAMES=${manifest_names[*]}" >> $GITHUB_OUTPUT
- name: Debug
- name: Add Compressed Images to Manifests (Multiple)
if: steps.metadata.outputs.COMPRESSION_FORMAT_COUNT > 1
id: add-to-manifests
shell: bash
env:
SANITIZED_COMPRESSION_FORMATS: ${{ steps.tag-compressed.outputs.SANITIZED_COMPRESSION_FORMATS }}
COMPRESSION_IMAGE_FULL: ${{ steps.metadata.outputs.COMPRESSION_IMAGE_FULL }}
MANIFEST_NAMES: ${{ steps.create-manifests.outputs.MANIFEST_NAMES }}
run: |
podman image ls
echo "SANITIZED_COMPRESSION_FORMATS=${{ steps.tag-compressed.outputs.SANITIZED_COMPRESSION_FORMATS }}"
echo "TAGGED_COMPRESSION_IMAGES=${{ steps.tag-compressed.outputs.TAGGED_COMPRESSION_IMAGES }}"
echo "COMPRESSION_FORMATS=${{ inputs.compression-formats }}"
echo "COMPRESSION_TAG=${{ steps.metadata.outputs.COMPRESSION_TAG }}"
echo "COMPRESSION_IMAGE_FULL=${{ steps.metadata.outputs.COMPRESSION_IMAGE_FULL }}"
echo "MANIFEST_NAMES=${{ steps.create-manifests.outputs.MANIFEST_NAMES }}"
IFS=' ' read -r -a sanitized_compression_formats_array <<< "${SANITIZED_COMPRESSION_FORMATS}"
IFS=' ' read -r -a manifest_names_array <<< "${MANIFEST_NAMES}"
for manifest_name in "${manifest_names_array[@]}"; do
for format in "${sanitized_compression_formats_array[@]}"; do
echo "Adding ${COMPRESSION_IMAGE_FULL}-${format} to ${manifest_name}"
if [[ "${format}" == zstd* ]]; then
echo "Adding zstd compression annotation to ${COMPRESSION_IMAGE_FULL}-${format}"
podman manifest add --annotation="io.github.containers.compression.zstd=true" ${manifest_name} ${COMPRESSION_IMAGE_FULL}-${format}
else
podman manifest add ${manifest_name} ${COMPRESSION_IMAGE_FULL}-${format}
fi
done
done
- name: Push Manifests (Multiple)
if: steps.metadata.outputs.COMPRESSION_FORMAT_COUNT
id: push-manifests
shell: bash
env:
MANIFEST_NAMES: ${{ steps.create-manifests.outputs.MANIFEST_NAMES }}
RETRIES: ${{ inputs.retries }}
run: |
IFS=' ' read -r -a manifest_names_array <<< "${MANIFEST_NAMES}"
manifest_digests=()
for manifest_name in "${manifest_names_array[@]}"; do
echo "Pushing manifest ${manifest_name}..."
${GITHUB_ACTION_PATH}/helpers/retry.sh ${RETRIES} podman manifest push --all=false --format="${IMAGE_FORMAT}" ${manifest_name}
manifest_digests+=($(skopeo inspect docker://${manifest_name} --format '{{.Digest}}'))
done
echo "DIGEST=${manifest_digests[0]}" >> $GITHUB_ENV
- name: Set Outputs
id: set-outputs
Expand Down

0 comments on commit fb0d72f

Please sign in to comment.