-
Notifications
You must be signed in to change notification settings - Fork 82
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Generate Docker Hub Description with current tags (#708)
Generate Docker Hub Description with current tags
- Loading branch information
1 parent
82f50b5
commit 44022e8
Showing
3 changed files
with
71 additions
and
16 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,50 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -eEuo pipefail ${RUNNER_DEBUG:+-x} | ||
|
||
get_formatted_latest_docker_tags() { | ||
local REPO_NAME=$1 | ||
local PAGE=1 | ||
local TAGS="" | ||
while true; do | ||
local RESPONSE=$(curl -s "https://hub.docker.com/v2/repositories/$REPO_NAME/tags/?page=${PAGE}&page_size=100") | ||
local CURRENT_TAGS=$(echo "${RESPONSE}" | jq -r '.results | group_by(.full_size) | .[] | {image: .[0].name, tags: [.[].name]}') | ||
local TAGS="${TAGS}${CURRENT_TAGS}" | ||
local HAS_NEXT=$(echo "${RESPONSE}" | jq -r '.next') | ||
if [ "$HAS_NEXT" == "null" ]; then | ||
break | ||
else | ||
PAGE=$((PAGE + 1)) | ||
fi | ||
done | ||
|
||
local LATEST_TAGS=$(echo "${TAGS}" | jq -sr '.[] | select( | ||
any(.tags[]; match("^5\\..(-slim)?$|latest")) | ||
)') | ||
|
||
echo "${LATEST_TAGS}"| jq -sr '.[] | " - " + (.tags | sort_by(.) | join(", "))' | sort -V | ||
} | ||
|
||
fill_readme_with_tags() { | ||
local filename=$1 | ||
local repo_name=$2 | ||
local matching_line="$3" | ||
local tags_file="tags-$(basename "$repo_name").md" | ||
get_formatted_latest_docker_tags "$repo_name" > "$tags_file" | ||
|
||
sed -i -e "/$matching_line/ { | ||
a\ | ||
a\ | ||
#### Latest Versions | ||
a\ | ||
r $tags_file | ||
}" "$filename" | ||
|
||
rm "$tags_file" | ||
} | ||
|
||
cp README.md README-docker.md | ||
fill_readme_with_tags README-docker.md "hazelcast/hazelcast" "### Hazelcast Versions" | ||
fill_readme_with_tags README-docker.md "hazelcast/hazelcast-enterprise" "### Hazelcast Enterprise Versions" |
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
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