Modern Docker Management, Designed for Everyone
Go composecontainer-managementcontainersdockerdocker-composedocker-managementgoself-hostedsveltekittypescriptweb-ui
chore: fix prune workflow
Kyle Mendell33220cfcc801
diff --git a/.depot/workflows/prune-ecr-public-next-images.yml b/.depot/workflows/prune-ecr-public-next-images.ymlindex 2dcdda5e9..03133715d 100644--- a/.depot/workflows/prune-ecr-public-next-images.yml+++ b/.depot/workflows/prune-ecr-public-next-images.yml@@ -18,6 +18,7 @@ jobs:image: g7r5wqb57k.registry.depot.dev/ci:latestenv:AWS_REGION: us-east-1+ TZ: UTCAWS_ACCESS_KEY_ID: ${{ secrets.ECR_PUBLIC_ACCESS_KEY_ID }}AWS_SECRET_ACCESS_KEY: ${{ secrets.ECR_PUBLIC_SECRET_ACCESS_KEY }}@@ -31,17 +32,23 @@ jobs:- name: Delete stale next imagesrun: |- # Release and next tags stay; only untagged manifests no longer referenced by any tag are removed.+ # Release and next tags stay, along with the manifests they reference and cosign referrers that point at them.# ECR Public has no lifecycle policies, so this keeps overwritten next images from eating the free tier.cutoff=$(date -u -d '1 hour ago' +%FT%T)for repo in manager agent; do+ image="public.ecr.aws/getarcaneapp/$repo"aws ecr-public describe-images --repository-name "$repo" --output json > "$RUNNER_TEMP/images.json"jq -r '.imageDetails[] | select(.imageTags) | .imageDigest' "$RUNNER_TEMP/images.json" > "$RUNNER_TEMP/tagged.txt"while read -r digest; do- docker buildx imagetools inspect "public.ecr.aws/getarcaneapp/$repo@$digest" --raw | jq -r '.manifests[]?.digest'+ docker buildx imagetools inspect "$image@$digest" --raw | jq -r '.manifests[]?.digest'done < "$RUNNER_TEMP/tagged.txt" | cat - "$RUNNER_TEMP/tagged.txt" | sort -u > "$RUNNER_TEMP/keep.txt"- jq -r --arg cutoff "$cutoff" '.imageDetails[] | select((.imageTags | not) and .imagePushedAt < $cutoff) | .imageDigest' "$RUNNER_TEMP/images.json" \- | sort -u | comm -23 - "$RUNNER_TEMP/keep.txt" > "$RUNNER_TEMP/delete.txt"+ : > "$RUNNER_TEMP/delete.txt"+ while read -r digest; do+ subject=$(docker buildx imagetools inspect "$image@$digest" --raw | jq -r '.subject.digest // empty')+ if [[ -z "$subject" ]] || ! grep -qxF "$subject" "$RUNNER_TEMP/keep.txt"; then+ echo "$digest" >> "$RUNNER_TEMP/delete.txt"+ fi+ done < <(jq -r --arg cutoff "$cutoff" '.imageDetails[] | select((.imageTags | not) and .imagePushedAt < $cutoff) | .imageDigest' "$RUNNER_TEMP/images.json" | sort -u | comm -23 - "$RUNNER_TEMP/keep.txt")sed 's/^/imageDigest=/' "$RUNNER_TEMP/delete.txt" | xargs -r -n 100 aws ecr-public batch-delete-image --repository-name "$repo" --image-ids > /dev/nullecho "$repo: deleted $(wc -l < "$RUNNER_TEMP/delete.txt" | tr -d ' ') stale manifests" >> "$GITHUB_STEP_SUMMARY"done