From 5ccb0e9993435dcf7305618f67a02b2c7007744e Mon Sep 17 00:00:00 2001 From: lotyp Date: Fri, 5 Apr 2024 15:54:24 +0300 Subject: [PATCH] ci: changes --- .github/workflows/build.yml | 80 ++++++++++++++++++++++++++----------- 1 file changed, 57 insertions(+), 23 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index e36b940..bda8a91 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -194,37 +194,71 @@ jobs: - name: Create manifest list and push run: | - # Debug: List all matching meta files - echo "Listing all bake-meta-*.json files for debugging:" - ls -la /tmp/bake-meta-*.json - - # Aggregate all tags from the meta files - TAGS=$(jq -r '.target."docker-metadata-action".tags[]' /tmp/bake-meta-*.json | sort -u) - echo "Found tags: $TAGS" + for FILE in $(find /tmp -name 'bake-meta-*.json'); do + echo "Processing file: $FILE" + cat "$FILE" | jq + done - # Loop through each tag and create a manifest list for TAG in $TAGS; do echo "Processing tag: $TAG" FULL_TAGS=() - for FILE in /tmp/bake-meta-*.json; do - if [ -d "$FILE" ]; then - echo "$FILE is a directory, skipping..." - continue + for FILE in $(find /tmp -name 'bake-meta-*.json'); do + echo "Processing file: $FILE" + # Debug: Print the structure of the JSON file + cat "$FILE" | jq + + REPO=$(jq -r --arg TAG "$TAG" '.target."docker-metadata-action".tags[] | select(. == $TAG)' $FILE | cut -d':' -f1) + DIGEST=$(jq -r --arg REPO "$REPO" '.["'$REPO'"]["containerimage.digest"]' $FILE) + + if [ "$DIGEST" == "null" ] || [ -z "$DIGEST" ]; then + echo "Digest not found for $REPO in $FILE" + continue # Skip adding this to FULL_TAGS fi - if jq -e --arg TAG "$TAG" '.target."docker-metadata-action".tags[] | select(. == $TAG)' $FILE > /dev/null; then - # Extract the repository and digest for the current platform - REPO=$(jq -r --arg TAG "$TAG" '.target."docker-metadata-action".tags[] | select(. == $TAG)' $FILE | cut -d':' -f1) - DIGEST=$(jq -r '.["'$REPO'"]["containerimage.digest"]' $FILE) - echo "Adding $REPO@$DIGEST to FULL_TAGS" + + echo "Adding $REPO@$DIGEST to FULL_TAGS" FULL_TAGS+=("$REPO@$DIGEST") - fi - done + done - # Debug: Print FULL_TAGS before creating the manifest - echo "FULL_TAGS for $TAG: ${FULL_TAGS[@]}" + if [ ${#FULL_TAGS[@]} -eq 0 ]; then + echo "No valid digests found for tag $TAG, skipping..." + continue + fi - # Create and push the manifest list for the current tag - docker buildx imagetools create "${FULL_TAGS[@]}" -t "$TAG" + echo "FULL_TAGS for $TAG: ${FULL_TAGS[@]}" + docker buildx imagetools create "${FULL_TAGS[@]}" -t "$TAG" done +# # Debug: List all matching meta files +# echo "Listing all bake-meta-*.json files for debugging:" +# ls -la /tmp/bake-meta-*.json +# +# # Aggregate all tags from the meta files +# TAGS=$(jq -r '.target."docker-metadata-action".tags[]' /tmp/bake-meta-*.json | sort -u) +# echo "Found tags: $TAGS" +# +# # Loop through each tag and create a manifest list +# for TAG in $TAGS; do +# echo "Processing tag: $TAG" +# FULL_TAGS=() +# for FILE in /tmp/bake-meta-*.json; do +# if [ -d "$FILE" ]; then +# echo "$FILE is a directory, skipping..." +# continue +# fi +# if jq -e --arg TAG "$TAG" '.target."docker-metadata-action".tags[] | select(. == $TAG)' $FILE > /dev/null; then +# # Extract the repository and digest for the current platform +# REPO=$(jq -r --arg TAG "$TAG" '.target."docker-metadata-action".tags[] | select(. == $TAG)' $FILE | cut -d':' -f1) +# DIGEST=$(jq -r '.["'$REPO'"]["containerimage.digest"]' $FILE) +# echo "Adding $REPO@$DIGEST to FULL_TAGS" +# FULL_TAGS+=("$REPO@$DIGEST") +# fi +# done +# +# # Debug: Print FULL_TAGS before creating the manifest +# echo "FULL_TAGS for $TAG: ${FULL_TAGS[@]}" +# +# # Create and push the manifest list for the current tag +# docker buildx imagetools create "${FULL_TAGS[@]}" -t "$TAG" +# done + ...