Skip to content

Commit d4d7bdb

Browse files
committed
update workflows
1 parent 5cf910d commit d4d7bdb

File tree

1 file changed

+44
-12
lines changed

1 file changed

+44
-12
lines changed

.github/actions/1-addition/1-maps/action.yml

Lines changed: 44 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -206,17 +206,49 @@ runs:
206206
207207
DELETED_MANIFESTS=0
208208
for SHA in $MANIFESTS; do
209-
echo "Deleting manifest ${SHA:0:12}..."
210-
RESPONSE=$(curl -s -o /dev/null -w "%{http_code}" -X DELETE \
211-
-H "Authorization: JWT $HUB_TOKEN" \
212-
"https://hub.docker.com/v2/repositories/${{ inputs.image_name }}/manifests/$SHA")
213-
214-
if [ "$RESPONSE" -eq 202 ]; then
215-
((DELETED_MANIFESTS++))
216-
echo "✅ Deleted manifest"
217-
sleep 1
218-
else
219-
echo "❌ Failed to delete (HTTP $RESPONSE)"
209+
echo "Processing manifest ${SHA:0:12}..."
210+
211+
# 1. Handle SHA256 prefix (some APIs need it, some don't)
212+
CLEAN_SHA="${SHA#sha256:}"
213+
214+
# 2. Try two different API endpoints
215+
ENDPOINTS=(
216+
"https://hub.docker.com/v2/repositories/$IMAGE_NAME/manifests/sha256:$CLEAN_SHA"
217+
"https://hub.docker.com/v2/namespaces/${IMAGE_NAME%/*}/repositories/${IMAGE_NAME#*/}/manifests/sha256:$CLEAN_SHA"
218+
)
219+
220+
for DELETE_URL in "${ENDPOINTS[@]}"; do
221+
echo "Trying endpoint: ${DELETE_URL//$CLEAN_SHA/***}"
222+
223+
# 3. Make the request with full debugging
224+
RESPONSE=$(curl -v -s -o /dev/null -w "%{http_code}" -X DELETE \
225+
-H "Authorization: JWT $HUB_TOKEN" \
226+
-H "Accept: application/json" \
227+
"$DELETE_URL" 2> curl_debug.log)
228+
229+
# 4. Check response
230+
if [ "$RESPONSE" -eq 202 ]; then
231+
((DELETED_MANIFESTS++))
232+
echo "✅ Successfully deleted manifest"
233+
# Show successful response headers
234+
grep "< HTTP/2" curl_debug.log | head -5
235+
break
236+
else
237+
echo "❌ Failed (HTTP $RESPONSE)"
238+
# Show error details
239+
grep -E "< HTTP/2|error" curl_debug.log || cat curl_debug.log
240+
fi
241+
done
242+
243+
# 5. Verify token is still valid
244+
if [ "$RESPONSE" -eq 401 ]; then
245+
echo "🔄 Token expired, refreshing..."
246+
HUB_TOKEN=$(curl -s -H "Content-Type: application/json" -X POST \
247+
-d "{\"username\": \"$HUB_USERNAME\", \"password\": \"$HUB_PASSWORD\"}" \
248+
https://hub.docker.com/v2/users/login/ | jq -r .token)
220249
fi
250+
251+
sleep 3 # Conservative rate limiting
221252
done
222-
echo "Deleted manifests: $DELETED_MANIFESTS"
253+
echo "Total manifests deleted: $DELETED_MANIFESTS/$MAX_DELETIONS"
254+
rm -f curl_debug.log

0 commit comments

Comments
 (0)