Skip to content

Commit

Permalink
Add helper script for image digests
Browse files Browse the repository at this point in the history
Signed-off-by: Alexandr Demicev <alexandr.demicev@suse.com>
  • Loading branch information
alexander-demicev committed Oct 4, 2023
1 parent f135e3f commit cecb76d
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions scripts/image-digest.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/bin/bash

# Run your command and capture its output
output=$(make docker-list-all REGISTRY="$1" ORG="$2" TAG="$3")

# Use a for loop to iterate over each line
IFS=$'\n' # Set the Internal Field Separator to newline
line_count=0 # Counter to keep track of the current line
total_lines=$(echo "$output" | wc -l) # Get the total number of lines
githubimageoutput=("multiarch_image" "amd64_image" "arm64_image" "s390x_image")
githubdigestoutput=("multiarch_digest" "amd64_digest" "arm64_digest" "s390x_digest")

for line in $output; do
# Run the Docker command and get the digest
digest=$(docker buildx imagetools inspect "$line" --format '{{json .}}' | jq -r .manifest.digest)

# Add image name and digest to the output
echo "${githubimageoutput[$line_count]}=$line" >> "$GITHUB_OUTPUT"
echo "${githubdigestoutput[$line_count]}=$digest" >> "$GITHUB_OUTPUT"

# Increment the line counter
line_count=$((line_count + 1))
done

0 comments on commit cecb76d

Please sign in to comment.