Skip to content

Commit 9961b66

Browse files
committed
Reduce builds
1 parent 2d0a0f0 commit 9961b66

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

hooks/common

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,26 +6,25 @@ IS_MASTER_BUILD=$([ "$SOURCE_BRANCH" == "master" ] && echo 1 || echo 0)
66
# return list of "<fromTag>|<targetTag>" depending if we are building against master or a specific release
77
getBuildParams() {
88
local RELEASE=$(echo $SOURCE_BRANCH | cut -c2-)
9-
# get top 5 x.y, then for each get top 3 x.y.z.
109
local TAGS=""
1110

1211
if [ $IS_MASTER_BUILD -eq 1 ]; then
13-
TAGS=$(curl 'https://registry.hub.docker.com/v2/repositories/library/nginx/tags?page_size=1024&name=alpine' 2>/dev/null | grep -Po '"name":"([0-9]+\.[0-9]+-alpine)"' | cut -d'"' -f4 | sort -r | uniq | head -n5)
12+
TAGS=$(curl 'https://registry.hub.docker.com/v2/repositories/library/nginx/tags?page_size=1024&name=alpine' 2>/dev/null | grep -Po '"name":"([0-9]+\.[0-9]+-alpine)"' | cut -d'"' -f4 | sort -r | uniq | head -n3)
1413
for MTAG in $(echo "$TAGS" | grep "master"); do
1514
strippedTag=$(echo "${MTAG}" | cut -d'-' -f1)
1615
echo "${MTAG}|${strippedTag}-master"
1716
done
1817
else
19-
TAGS=$(curl 'https://registry.hub.docker.com/v2/repositories/library/nginx/tags?page_size=1024&name=alpine' 2>/dev/null | grep -Po '"name":"([0-9]+\.[0-9]+-alpine)"' | cut -d'"' -f4 | cut -d'-' -f1 | sort -r | uniq | head -n5 | while read minor; do curl 'https://registry.hub.docker.com/v2/repositories/library/nginx/tags?page_size=1024&name=alpine' 2>/dev/null | grep -Po "\"name\":\"(${minor}\.[0-9]+-alpine)\"" | cut -d'"' -f4 | sort -r | uniq | head -n3; done)
18+
TAGS=$(curl 'https://registry.hub.docker.com/v2/repositories/library/nginx/tags?page_size=1024&name=alpine' 2>/dev/null | grep -Po '"name":"([0-9]+\.[0-9]+-alpine)"' | cut -d'"' -f4 | cut -d'-' -f1 | sort -r | uniq | head -n3 | while read minor; do curl 'https://registry.hub.docker.com/v2/repositories/library/nginx/tags?page_size=1024&name=alpine' 2>/dev/null | grep -Po "\"name\":\"(${minor}\.[0-9]+-alpine)\"" | cut -d'"' -f4 | sort -r | uniq | head -n3; done)
2019
for MTAG in $(echo "$TAGS" | grep -v "master"); do
2120
strippedTag=$(echo "${MTAG}" | cut -d'-' -f1)
22-
echo "${MTAG}|${strippedTag}-${RELEASE}"
21+
echo "${MTAG}|${strippedTag}-v${RELEASE}"
2322
done
2423
25-
TAGS=$(curl 'https://registry.hub.docker.com/v2/repositories/library/nginx/tags?page_size=1024&name=alpine' 2>/dev/null | grep -Po '"name":"([0-9]+\.[0-9]+-alpine)"' | cut -d'"' -f4 | sort -r | uniq | head -n5)
24+
TAGS=$(curl 'https://registry.hub.docker.com/v2/repositories/library/nginx/tags?page_size=1024&name=alpine' 2>/dev/null | grep -Po '"name":"([0-9]+\.[0-9]+-alpine)"' | cut -d'"' -f4 | sort -r | uniq | head -n3)
2625
for MTAG in $(echo "$TAGS" | grep -v "master"); do
2726
strippedTag=$(echo "${MTAG}" | cut -d'-' -f1)
28-
echo "${MTAG}|${strippedTag}-${RELEASE}"
27+
echo "${MTAG}|${strippedTag}-v${RELEASE}"
2928
done
3029
fi
3130
}

0 commit comments

Comments
 (0)