-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' of github.com:NVIDIA/JAX-Toolbox into pax-add-eva…
…l-test
- Loading branch information
Showing
32 changed files
with
701 additions
and
112 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
name: ~split multi-arch OCI manifests into Docker Image Manifest V2, Schema 2 | ||
|
||
on: | ||
workflow_call: | ||
inputs: | ||
SOURCE_IMAGE: | ||
type: string | ||
description: 'Source docker image:' | ||
required: true | ||
TARGET_TAGS: | ||
type: string | ||
description: 'Target docker tags in docker/metadata-action format:' | ||
required: true | ||
EXPOSE_SINGLE_ARCH_IMAGES: | ||
type: boolean | ||
description: 'Also expose single-arch images:' | ||
required: false | ||
default: true | ||
outputs: | ||
# MULTIARCH_TAG: | ||
# description: "Tags of the multi-arch image published" | ||
# value: ${{ jobs.publish.outputs.MULTIARCH_TAG }} | ||
SINGLEARCH_TAGS: | ||
description: "Tags of the single-arch images published" | ||
value: ${{ jobs.publish.outputs.SINGLEARCH_TAGS }} | ||
|
||
env: | ||
DOCKER_REPOSITORY: 'ghcr.io/nvidia/jax-toolbox-retrofit' | ||
|
||
jobs: | ||
publish: | ||
runs-on: ubuntu-22.04 | ||
outputs: | ||
# MULTIARCH_TAG: ${{ steps.meta.outputs.tags }} | ||
SINGLEARCH_TAGS: ${{ steps.single-arch.outputs.tags }} | ||
steps: | ||
- name: Login to GitHub Container Registry | ||
uses: docker/login-action@v2 | ||
with: | ||
registry: ghcr.io | ||
username: ${{ github.repository_owner }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Set docker metadata | ||
id: meta | ||
uses: docker/metadata-action@v4 | ||
with: | ||
images: ${{ env.DOCKER_REPOSITORY }} | ||
flavor: latest=false | ||
tags: ${{ inputs.TARGET_TAGS }} | ||
|
||
- name: Extract manifests from the source manifest list | ||
id: get-manifests | ||
shell: bash -x -e {0} | ||
run: | | ||
SOURCE_REPO=$(echo ${{ inputs.SOURCE_IMAGE }} | cut -d: -f1) | ||
MEDIA_TYPE=$(docker manifest inspect ${{ inputs.SOURCE_IMAGE }} | jq -r '.mediaType') | ||
if [[ ${MEDIA_TYPE} != "application/vnd.oci.image.index.v1+json" ]]; then | ||
echo "This workflow only work with OCI manifest lists" | ||
exit 1 | ||
fi | ||
MANIFESTS=$( | ||
docker manifest inspect ${{ inputs.SOURCE_IMAGE }} |\ | ||
jq -r '.manifests[] | select(.platform.os != "unknown") | .digest' |\ | ||
xargs -I{} echo ${SOURCE_REPO}@{} |\ | ||
tr '\n' ' ' | ||
) | ||
echo "manifests=$MANIFESTS" >> $GITHUB_OUTPUT | ||
## Requires skopeo >= v1.6.0, but Actions only has v1.4.0 | ||
# - name: Create Docker v2s2 multi-arch manifest list | ||
# id: multi-arch | ||
# shell: bash -x -e {0} | ||
# run: | | ||
# for tag in $(echo "${{ steps.meta.outputs.tags }}"); do | ||
# skopeo copy --multi-arch all --format v2s2 docker://${{ inputs.SOURCE_IMAGE }} docker://$tag | ||
# done | ||
|
||
- name: Create Docker v2s2 single-arch manifests | ||
id: single-arch | ||
if: ${{ inputs.EXPOSE_SINGLE_ARCH_IMAGES }} | ||
shell: bash -x -e {0} | ||
run: | | ||
output_tags="" | ||
# Create new manifest list from extracted manifests | ||
for manifest in ${{ steps.get-manifests.outputs.manifests }}; do | ||
os=$(docker manifest inspect -v $manifest | jq -r '.Descriptor.platform.os') | ||
arch=$(docker manifest inspect -v $manifest | jq -r '.Descriptor.platform.architecture') | ||
for tag in $(echo "${{ steps.meta.outputs.tags }}"); do | ||
single_arch_tag="${tag}-${os}-${arch}" | ||
skopeo copy --format v2s2 docker://$manifest docker://${single_arch_tag} | ||
output_tags="${output_tags} ${single_arch_tag}" | ||
done | ||
done | ||
echo "tags=${output_tags}" >> $GITHUB_OUTPUT |
Oops, something went wrong.