@@ -187,71 +187,13 @@ runs:
187187 configFile : ${{ inputs.action_path }}/.devcontainer.json
188188 push : ${{ env.RERUN_RUNNER == 'true' && 'always' || 'never' }}
189189
190- - name : 🗑️ Delete 15 Oldest Docker Images
191- id : variables
190+ - name : 🗑️ Delete Docker Tags AND Images
191+ id : delete_images
192192 shell : bash
193193 env :
194194 IMAGE_NAME : " ${{ inputs.image_name }}"
195195 HUB_USERNAME : " ${{ inputs.hub_username }}"
196196 HUB_PASSWORD : " ${{ inputs.hub_password }}"
197197 MAX_DELETIONS : 15
198198 run : |
199- echo "Fetching manifests to delete..."
200- HUB_TOKEN=$(curl -s -H "Content-Type: application/json" -X POST \
201- -d "{\"username\": \"${{ inputs.hub_username }}\", \"password\": \"${{ inputs.hub_password }}\"}" \
202- https://hub.docker.com/v2/users/login/ | jq -r .token)
203- [ -z "$HUB_TOKEN" ] && { echo "❌ Authentication failed"; exit 1; }
204-
205- MANIFESTS=$(curl -s -H "Authorization: JWT $HUB_TOKEN" \
206- "https://hub.docker.com/v2/repositories/${{ inputs.image_name }}/tags/?page_size=${{ env.MAX_DELETIONS }}&ordering=last_updated" \
207- | jq -r '.results[] | select(.images != null) | .images[].digest' \
208- | sort | uniq | head -n ${{ env.MAX_DELETIONS }})
209-
210- DELETED_MANIFESTS=0
211- for SHA in $MANIFESTS; do
212- echo "Processing manifest ${SHA:0:12}..."
213-
214- # 1. Handle SHA256 prefix (some APIs need it, some don't)
215- CLEAN_SHA="${SHA#sha256:}"
216-
217- # 2. Try two different API endpoints
218- ENDPOINTS=(
219- " https://hub.docker.com/v2/repositories/$IMAGE_NAME/manifests/sha256:$CLEAN_SHA"
220- " https://hub.docker.com/v2/namespaces/${IMAGE_NAME%/*}/repositories/${IMAGE_NAME#*/}/manifests/sha256:$CLEAN_SHA"
221- )
222-
223- for DELETE_URL in "${ENDPOINTS[@]}"; do
224- echo "Trying endpoint : ${DELETE_URL//$CLEAN_SHA/***}"
225-
226- # 3. Make the request with full debugging
227- RESPONSE=$(curl -v -s -o /dev/null -w "%{http_code}" -X DELETE \
228- -H "Authorization : JWT $HUB_TOKEN" \
229- -H "Accept : application/json" \
230- " $DELETE_URL" 2> curl_debug.log)
231-
232- # 4. Check response
233- if [ "$RESPONSE" -eq 202 ]; then
234- ((DELETED_MANIFESTS++))
235- echo "✅ Successfully deleted manifest"
236- # Show successful response headers
237- grep "< HTTP/2" curl_debug.log | head -5
238- break
239- else
240- echo "❌ Failed (HTTP $RESPONSE)"
241- # Show error details
242- grep -E "< HTTP/2|error" curl_debug.log || cat curl_debug.log
243- fi
244- done
245-
246- # 5. Verify token is still valid
247- if [ "$RESPONSE" -eq 401 ]; then
248- echo "🔄 Token expired, refreshing..."
249- HUB_TOKEN=$(curl -s -H "Content-Type : application/json" -X POST \
250- -d "{\"username\" : \"$HUB_USERNAME\", \"password\": \"$HUB_PASSWORD\"}" \
251- https://hub.docker.com/v2/users/login/ | jq -r .token)
252- fi
253-
254- sleep 3 # Conservative rate limiting
255- done
256- echo "Total manifests deleted : $DELETED_MANIFESTS/$MAX_DELETIONS"
257- rm -f curl_debug.log
199+ ./.github/entrypoint/remote.sh
0 commit comments