devx/fetch-docker.sh
Hamish Mackenzie 4e8dc4896a
Use ghcr.io to store closure (#39)
---------

Co-authored-by: Yvan Sraka <yvan@sraka.xyz>
Co-authored-by: Moritz Angermann <moritz.angermann@gmail.com>
Co-authored-by: Andrea Bedini <andrea.bedini@tweag.io>
2023-04-26 14:56:35 +08:00

19 lines
608 B
Bash
Executable File

#!/bin/bash
TOKEN=$(curl --silent https://ghcr.io/token\?scope\=repository:$1:pull | jq -r .token)
BLOB=$(curl \
--silent \
--request 'GET' \
--header "Authorization: Bearer $TOKEN" \
--header "Accept: application/vnd.docker.distribution.manifest.list.v2+json" \
--header "Accept: application/vnd.docker.distribution.manifest.v2+json" \
--header "Accept: application/vnd.oci.image.manifest.v1+json" \
"https://ghcr.io/v2/$1/manifests/$2" | tee manifest.json | jq -r '.layers[0].digest')
curl \
--location \
--request GET \
--header "Authorization: Bearer ${TOKEN}" \
"https://ghcr.io/v2/$1/blobs/${BLOB}"