-
Notifications
You must be signed in to change notification settings - Fork 4
feat: Publish Toolkit artifacts as OCI images #106
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
m1so
merged 4 commits into
main
from
michalbaumgartner/blu-6079-publish-toolkit-artifacts-as-oci-images
Jun 5, 2026
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
c2e15a7
feat: Publish Toolkit artifacts as OCI images
m1so 57c29d8
fix: Make artifacts compatible with Kubernetes Image Volumes
m1so c43da7d
chore: Dynamically build constraint files list
m1so f74a24a
Merge branch 'main' into michalbaumgartner/blu-6079-publish-toolkit-a…
m1so File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,103 @@ | ||
| name: 'Push OCI image volume artifact' | ||
| description: 'Push one or more files as an OCI image-volume-compatible artifact' | ||
| inputs: | ||
| artifact_ref: | ||
| description: 'Fully qualified OCI image reference' | ||
| required: true | ||
| artifact_type: | ||
| description: 'Logical artifact type label' | ||
| required: true | ||
| files: | ||
| description: 'Newline-separated file descriptors in path:media-type format. Media type is ignored for image-volume publishing.' | ||
| required: true | ||
| toolkit_version: | ||
| description: 'Toolkit version annotation value' | ||
| required: true | ||
| annotations: | ||
| description: 'Additional newline-separated OCI annotations in key=value format' | ||
| default: '' | ||
|
|
||
| runs: | ||
| using: "composite" | ||
|
|
||
| steps: | ||
| - name: Set up ORAS | ||
| uses: oras-project/setup-oras@38de303aac69abb66f3e6255b7198bff35f323e3 # v2.0.0 | ||
|
|
||
| - name: Push OCI image volume artifact | ||
| shell: bash | ||
| env: | ||
| ARTIFACT_REF: ${{ inputs.artifact_ref }} | ||
| ARTIFACT_TYPE: ${{ inputs.artifact_type }} | ||
| FILES: ${{ inputs.files }} | ||
| TOOLKIT_VERSION: ${{ inputs.toolkit_version }} | ||
| EXTRA_ANNOTATIONS: ${{ inputs.annotations }} | ||
| run: | | ||
| set -euo pipefail | ||
|
|
||
| workdir="$(mktemp -d)" | ||
| trap 'rm -rf "${workdir}"' EXIT | ||
|
|
||
| rootfs_dir="${workdir}/rootfs" | ||
| mkdir -p "${rootfs_dir}" | ||
|
|
||
| manifest_annotations=( | ||
| "org.opencontainers.image.source=https://github.com/${GITHUB_REPOSITORY}" | ||
| "org.opencontainers.image.revision=${GITHUB_SHA}" | ||
| "org.opencontainers.image.version=${TOOLKIT_VERSION}" | ||
| "com.deepnote.toolkit.artifact-type=${ARTIFACT_TYPE}" | ||
| ) | ||
|
|
||
| while IFS= read -r annotation; do | ||
| [ -n "${annotation}" ] || continue | ||
| manifest_annotations+=("${annotation}") | ||
| done <<< "${EXTRA_ANNOTATIONS}" | ||
|
|
||
| while IFS= read -r file_descriptor; do | ||
| [ -n "${file_descriptor}" ] || continue | ||
| file_path="${file_descriptor%%:*}" | ||
| if [ ! -f "${file_path}" ]; then | ||
| echo "Error: OCI artifact file not found at ${file_path}" >&2 | ||
| ls -la "$(dirname "${file_path}")" >&2 || true | ||
| exit 1 | ||
| fi | ||
| cp "${file_path}" "${rootfs_dir}/$(basename "${file_path}")" | ||
| done <<< "${FILES}" | ||
|
coderabbitai[bot] marked this conversation as resolved.
|
||
|
|
||
| layer_tar="${workdir}/rootfs.tar" | ||
| layer_tar_gz="${workdir}/rootfs.tar.gz" | ||
| tar -C "${rootfs_dir}" -cf "${layer_tar}" . | ||
| gzip -n -c "${layer_tar}" > "${layer_tar_gz}" | ||
|
|
||
| layer_diff_id="$(sha256sum "${layer_tar}" | awk '{print $1}')" | ||
|
|
||
| config_path="${workdir}/config.json" | ||
| cat > "${config_path}" <<EOF | ||
| { | ||
| "architecture": "amd64", | ||
| "os": "linux", | ||
| "rootfs": { | ||
| "type": "layers", | ||
| "diff_ids": ["sha256:${layer_diff_id}"] | ||
| }, | ||
| "config": {}, | ||
| "history": [{"created_by": "deepnote-toolkit OCI image volume artifact"}] | ||
| } | ||
| EOF | ||
|
|
||
| ( | ||
| cd "${workdir}" | ||
| oras_args=( | ||
| push | ||
| "${ARTIFACT_REF}" | ||
| --config "config.json:application/vnd.oci.image.config.v1+json" | ||
| ) | ||
| for annotation in "${manifest_annotations[@]}"; do | ||
| oras_args+=(--annotation "${annotation}") | ||
| done | ||
| oras_args+=("rootfs.tar.gz:application/vnd.oci.image.layer.v1.tar+gzip") | ||
|
|
||
| oras "${oras_args[@]}" | ||
| ) | ||
| oras manifest fetch "${ARTIFACT_REF}" >/dev/null | ||
| echo "Pushed ${ARTIFACT_REF}" | ||
This file contains hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.