-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
18f3e04
commit 565f6fa
Showing
3 changed files
with
146 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
#!/bin/bash | ||
|
||
# Initialize array to store digest SHAs | ||
declare -a digests | ||
|
||
image_names=$(gh api \ | ||
-H 'Accept: application/vnd.github+json' \ | ||
-H '-GitHub-Api-Version: 2022-11-28' \ | ||
--paginate '/orgs/boozallen/packages?package_type=container' | jq -r '.[] | select((.name | startswith("aissemble")) and (.name | endswith("-chart") | not)) | .name') | ||
|
||
for name in $image_names; do | ||
echo "Processing image: $name" | ||
|
||
release_versions=$(gh api \ | ||
-H 'Accept: application/vnd.github+json' \ | ||
-H '-GitHub-Api-Version: 2022-11-28' \ | ||
--paginate /orgs/boozallen/packages/container/"$name"/versions \ | ||
| jq -r '.[] | .metadata.container.tags[] | select(test("^\\d+\\.\\d+\\.\\d?$"))' | \ | ||
jq -R -s 'split("\n") | map(select(length > 0)) | map(select(. != "1.7.0" and . != "1.7.0-arm64" and . != "1.7.0-amd64"))') | ||
|
||
echo "All Release Versions:" | ||
echo "$release_versions" | ||
|
||
for version in $(echo "$release_versions" | jq -r '.[]'); do | ||
|
||
echo "Processing release_version: $version" | ||
manifest_list_shas=$(docker buildx imagetools inspect --raw "${REGISTRY}/${ORG}/${name}:${version}" | jq -r '.manifests[].digest' | paste -s -d ' ' -) | ||
|
||
echo "Manifest List: $manifest_list_shas" | ||
digests+=("$manifest_list_shas") | ||
echo "Digests: $digests" | ||
done | ||
|
||
done | ||
|
||
# Join digests into a single string separated by spaces | ||
digests_string=$(echo "${digests[*]}") | ||
|
||
# Save the output to $GITHUB_OUTPUT | ||
echo "${digests_string}" >> "$GITHUB_OUTPUT" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
#!/bin/bash | ||
|
||
# Initialize array to store digest SHAs | ||
declare -a digests | ||
|
||
image_names=$(gh api \ | ||
-H 'Accept: application/vnd.github+json' \ | ||
-H '-GitHub-Api-Version: 2022-11-28' \ | ||
--paginate '/orgs/boozallen/packages?package_type=container' | jq -r '.[] | select((.name | startswith("aissemble")) and (.name | endswith("-chart") | not)) | .name') | ||
|
||
for name in $image_names; do | ||
echo "Processing image: $name" | ||
|
||
all_snapshot_versions=$(gh api \ | ||
-H 'Accept: application/vnd.github+json' \ | ||
-H '-GitHub-Api-Version: 2022-11-28' \ | ||
--paginate /orgs/boozallen/packages/container/"$name"/versions \ | ||
| jq -r '.[] | .metadata.container.tags[] | select(test("-SNAPSHOT(-arm64|-amd64)?$"))'| jq -R -s 'split("\n")') | ||
|
||
echo "All Snapshot Versions:" | ||
echo $all_snapshot_versions | ||
|
||
latest_snapshot_version=$(echo "$all_snapshot_versions" | jq -r '.[] | select(endswith("-SNAPSHOT"))' | sort | tail -n 1) | ||
echo "Latest Snapshot Version: $latest_snapshot_version" | ||
|
||
version_part="${latest_snapshot_version%-SNAPSHOT}" | ||
|
||
# Extract the major, minor, and patch components using IFS (Internal Field Separator) | ||
IFS='.' read -r major minor patch <<< "$version_part" | ||
echo "Major: $major" | ||
echo "Minor: $minor" | ||
echo "Patch: $patch" | ||
|
||
previous_minor=$((minor - 1)) | ||
echo "Previous minor: $previous_minor" | ||
# Check if previous_minor is valid (not negative) | ||
if [ $previous_minor -ge 0 ]; then | ||
patch_pattern=${major}.${previous_minor}.[1-9]-SNAPSHOT$ | ||
|
||
for version in $(echo "$all_snapshot_versions" | jq -r '.[]'); do | ||
if [[ $version =~ ^${patch_pattern}$ ]]; then | ||
|
||
echo "Existing Patch Version found: $version" | ||
all_patch_versions+=("$version") | ||
|
||
# Print the array to verify | ||
echo "All Patch Versions array: " | ||
echo $(printf "%s\n" ${all_patch_versions[@]}) | ||
|
||
sorted_versions=($(printf "%s\n" "${all_patch_versions[@]}" | sort -V)) | ||
echo "Sorted Versions:" | ||
echo "${sorted_versions[@]}" | ||
latest_patch_version=($(printf "%s\n" "${all_patch_versions[@]}" | sort -V | tail -n 1)) | ||
|
||
echo "Latest Patch Version: $latest_patch_version" | ||
latest_patch_version_digest=$(docker buildx imagetools inspect --raw "ghcr.io/boozallen/${name}:${latest_patch_version}" | jq -r '.manifests[].digest' | paste -s -d ' ' -) | ||
|
||
digests+=("$latest_patch_version_digest") | ||
|
||
fi | ||
done | ||
fi | ||
|
||
|
||
|
||
latest_snapshot_manifest_list_shas=$(docker buildx imagetools inspect --raw "${REGISTRY}/${ORG}/${name}:${latest_snapshot_version}" | jq -r '.manifests[].digest' | paste -s -d ' ' -) | ||
|
||
echo "Manifest List: $latest_snapshot_manifest_list_shas" | ||
digests+=("$latest_snapshot_manifest_list_shas") | ||
echo "Digests: $digests" | ||
|
||
done | ||
|
||
digests_string=$(echo "${digests[*]}") | ||
|
||
# Save the output to $GITHUB_OUTPUT | ||
echo "${digests_string}" >> "$GITHUB_OUTPUT" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters