-
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 d6566b0
Showing
3 changed files
with
129 additions
and
10 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,36 @@ | ||
#!/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" \ | ||
-H "Authorization: Token ${GITHUB_TOKEN}" \ | ||
--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 | ||
release_versions=$(gh api \ | ||
-H "Accept: application/vnd.github+json" \ | ||
-H "-GitHub-Api-Version: 2022-11-28" \ | ||
-H "Authorization: Token ${GITHUB_TOKEN}" \ | ||
--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"))') | ||
|
||
for version in $(echo "$release_versions" | jq -r '.[]'); do | ||
|
||
echo "Processing release image ${name}:${version}" | ||
manifest_list_shas=$(docker buildx imagetools inspect --raw "ghcr.io/boozallen/${name}:${version}" | jq -r '.manifests[].digest' | paste -s -d ' ' -) | ||
|
||
echo "Manifest List: $manifest_list_shas" | ||
digests+=("$manifest_list_shas") | ||
done | ||
done | ||
|
||
# Join digests into a single string separated by spaces | ||
digests_string=$(echo "${digests[*]}") | ||
#echo "Digest String: $digests_string" | ||
|
||
# Save the output to $GITHUB_OUTPUT | ||
echo "multi-arch-digests=${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,58 @@ | ||
#!/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" \ | ||
-H "Authorization: Token ${GITHUB_TOKEN}" \ | ||
--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 | ||
all_snapshot_versions=$(gh api \ | ||
-H "Accept: application/vnd.github+json" \ | ||
-H "-GitHub-Api-Version: 2022-11-28" \ | ||
-H "Authorization: Token ${GITHUB_TOKEN}" \ | ||
--paginate "/orgs/boozallen/packages/container/${name}/versions" \ | ||
| jq -r '.[] | .metadata.container.tags[] | select(test("-SNAPSHOT(-arm64|-amd64)?$"))'| jq -R -s 'split("\n")') | ||
|
||
latest_snapshot_version=$(echo "$all_snapshot_versions" | jq -r '.[] | select(endswith("-SNAPSHOT"))' | sort | tail -n 1) | ||
|
||
echo "Processing snapshot image ${name}:${latest_snapshot_version}" | ||
latest_snapshot_manifest_list_shas=$(docker buildx imagetools inspect --raw "ghcr.io/boozallen/${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") | ||
|
||
# Find if there are any patch versions from the previous minor available | ||
# Extract version from latest snapshot | ||
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" | ||
previous_minor=$((minor - 1)) | ||
# 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 | ||
# Found a patch version matching the given pattern | ||
all_patch_versions+=("$version") | ||
latest_patch_version=($(printf "%s\n" "${all_patch_versions[@]}" | sort -V | tail -n 1)) | ||
|
||
echo "Patch Version found: ${name}:${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 | ||
done | ||
|
||
digests_string=$(echo "${digests[*]}") | ||
#echo "Digest String: $digests_string" | ||
|
||
# Save the output to $GITHUB_OUTPUT | ||
echo "latest-snapshot-digests=${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