Skip to content

Commit

Permalink
Fixup unpublish step
Browse files Browse the repository at this point in the history
  • Loading branch information
joshwlewis committed Feb 21, 2024
1 parent 4aed1d7 commit 67172a9
Showing 1 changed file with 15 additions and 7 deletions.
22 changes: 15 additions & 7 deletions bin/unpublish-temp-tags.sh
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,27 @@
set -euo pipefail
set -x

dockerhub_token=$(curl -s -f -H "Content-Type: application/json" -X POST -d "{\"username\": \"${DOCKER_HUB_USERNAME}\", \"password\": \"${DOCKER_HUB_TOKEN}\"}" https://hub.docker.com/v2/users/login/ | jq -r .token)

unpublish_group() {
local tagBase="$1"
local stackVersion="$1"
local targetTagSuffix="$2"
variants=("" "-build")
if (( STACK_VERSION <= 22 )); then
if (( stackVersion <= 22 )); then
variants+=("-cnb" "-cnb-build")
fi
for variant in "${variants[@]}"; do
hub-tool tag rm "${tagBase}${variant}${targetTagSuffix}"
echo "Deleting heroku/heroku:${stackVersion}${variant}${targetTagSuffix}"
code=$(curl -s -f -X DELETE -H "Authorization: JWT ${dockerhub_token}" --write-out "%{http_code}"
"https://hub.docker.com/v2/repositories/heroku/heroku/tags/${stackVersion}${variant}${targetTagSuffix}/")

if (( code != 404 )) || (( code != 200 )) || (( code != 201 )); then
echo "Couldn't delete heroku/heroku:${stackVersion}${variant}${targetTagSuffix}: ${code}"
fi
done
}

publicTag="heroku/heroku:${STACK_VERSION}"
tempTagSuffix=".temp_${GITHUB_RUN_ID}"

unpublish_group "${publicTag}" "${tempTagSuffix}"
stackVersion="${1:-$STACK_VERSION}"
tempTagSuffix="${2:-".temp_$GITHUB_RUN_ID"}"
# delete each tag in a group on Docker Hub.
unpublish_group "${stackVersion}" "${tempTagSuffix}"

0 comments on commit 67172a9

Please sign in to comment.