From 955d3f7331ef1c8513c3b9d8206c2537d1bb6051 Mon Sep 17 00:00:00 2001 From: thespad Date: Wed, 4 Dec 2024 22:05:31 +0000 Subject: [PATCH] Fix handling of OCI indexes and manifests --- .../templates/EXTERNAL_TRIGGER.j2 | 36 +++++++++---------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/roles/generate-jenkins/templates/EXTERNAL_TRIGGER.j2 b/roles/generate-jenkins/templates/EXTERNAL_TRIGGER.j2 index 24bc4f50..b6ab0007 100644 --- a/roles/generate-jenkins/templates/EXTERNAL_TRIGGER.j2 +++ b/roles/generate-jenkins/templates/EXTERNAL_TRIGGER.j2 @@ -108,25 +108,25 @@ jobs: "https://ghcr.io/token?scope=repository%3A{{ better_vars.LS_USER }}%2F{{ project_name }}%3Apull" \ | jq -r '.token') {% if better_vars.MULTIARCH == 'true' %} - multidigest=$(curl -s \ - --header "Accept: application/vnd.docker.distribution.manifest.v2+json" \ - --header "Accept: application/vnd.oci.image.index.v1+json" \ - --header "Authorization: Bearer ${token}" \ - "https://ghcr.io/v2/${image}/manifests/${tag}" \ - | jq -r 'first(.manifests[].digest)') - digest=$(curl -s \ - --header "Accept: application/vnd.docker.distribution.manifest.v2+json" \ - --header "Accept: application/vnd.oci.image.index.v1+json" \ - --header "Authorization: Bearer ${token}" \ - "https://ghcr.io/v2/${image}/manifests/${multidigest}" \ - | jq -r '.config.digest') + multidigest=$(curl -s \ + --header "Accept: application/vnd.docker.distribution.manifest.v2+json" \ + --header "Accept: application/vnd.oci.image.index.v1+json" \ + --header "Authorization: Bearer ${token}" \ + "https://ghcr.io/v2/${image}/manifests/${tag}") + multidigest=$(jq -r ".manifests[] | select(.platform.architecture == \"amd64\").digest?" <<< "${multidigest}") + digest=$(curl -s \ + --header "Accept: application/vnd.docker.distribution.manifest.v2+json" \ + --header "Accept: application/vnd.oci.image.manifest.v1+json" \ + --header "Authorization: Bearer ${token}" \ + "https://ghcr.io/v2/${image}/manifests/${multidigest}" \ + | jq -r '.config.digest') {% else %} - digest=$(curl -s \ - --header "Accept: application/vnd.docker.distribution.manifest.v2+json" \ - --header "Accept: application/vnd.oci.image.index.v1+json" \ - --header "Authorization: Bearer ${token}" \ - "https://ghcr.io/v2/${image}/manifests/${tag}" \ - | jq -r '.config.digest') + digest=$(curl -s \ + --header "Accept: application/vnd.docker.distribution.manifest.v2+json" \ + --header "Accept: application/vnd.oci.image.manifest.v1+json" \ + --header "Authorization: Bearer ${token}" \ + "https://ghcr.io/v2/${image}/manifests/${tag}" \ + | jq -r '.config.digest') {% endif %} image_info=$(curl -sL \ --header "Authorization: Bearer ${token}" \