sort lastest

This commit is contained in:
nyyu 2023-10-03 07:50:47 +02:00
parent 957d49d9c9
commit 095fa57291

View File

@ -3,7 +3,7 @@ images=$(grep 'image:' docker-compose.yml | grep -v '#' | sed 's/^ *//' | cut -d
for image in $images for image in $images
do do
if [[ $image != gcr* ]]; then if [[ $image != gcr* ]]; then
ver=$(curl -s https://registry.hub.docker.com/v2/repositories/${image}/tags | jq -r '[.results[] | select(.name | contains("ubuntu") | not) | select(.name | contains("main") | not ) | select(.name | contains("master") | not ) | select(.name | contains("latest") | not) | select(.name | contains("rc") | not) | select(.name | contains("."))] | first | .name') ver=$(curl -s https://registry.hub.docker.com/v2/repositories/${image}/tags | jq -r '[.results[] | select(.name | contains("ubuntu") | not) | select(.name | contains("main") | not ) | select(.name | contains("master") | not ) | select(.name | contains("latest") | not) | select(.name | contains("rc") | not) | select(.name | contains("-") | not) | select(.name | contains("."))] | sort_by(.name|sub("^v";"")|split(".")|map(tonumber)) | reverse | first | .name')
echo "$image:$ver" echo "$image:$ver"
sed -i "s#image: $image:.*#image: $image:$ver#" docker-compose.yml sed -i "s#image: $image:.*#image: $image:$ver#" docker-compose.yml
fi fi