Skip to content

Commit

Permalink
ci: changes
Browse files Browse the repository at this point in the history
  • Loading branch information
lotyp committed Apr 5, 2024
1 parent 2ebac9b commit 5ccb0e9
Showing 1 changed file with 57 additions and 23 deletions.
80 changes: 57 additions & 23 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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

...

0 comments on commit 5ccb0e9

Please sign in to comment.