Skip to content

Commit eaa1192

Browse files
committed
New attempt to delete images from github packages
Signed-off-by: Marvin Froeder <marvin@datasqrl.com>
1 parent e851f05 commit eaa1192

File tree

1 file changed

+17
-11
lines changed

1 file changed

+17
-11
lines changed

.github/workflows/delete-pr-images.yml

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,29 +15,35 @@ jobs:
1515
steps:
1616
- name: Delete GHCR image
1717
run: |
18-
# Convert the repository name to lowercase for GHCR compatibility
19-
REPO=$(echo "${{ github.repository }}" | tr '[:upper:]' '[:lower:]')
18+
set -x
2019
21-
# Our PR image tag is pr-<number>-<flink_profile>
20+
# Hardcoded GHCR image repository
21+
REPO="datasqrl/flink-sql-runner"
22+
23+
# PR image tag is pr-<number>-<flink_profile>
2224
TAG="pr-${{ github.event.number }}-${{ matrix.FLINK_PROFILE }}"
23-
IMAGE="ghcr.io/$REPO/flink-jar-runner:$TAG"
25+
IMAGE="ghcr.io/$REPO:$TAG"
2426
2527
echo "Attempting to delete image: $IMAGE"
2628
27-
# Build the Basic Auth header from your PAT credentials
29+
# Build Basic Auth header from PAT credentials
2830
TOKEN_BASE64="$(echo -n "${{ secrets.PAT_USERNAME }}:${{ secrets.PAT_PASSWORD }}" | base64)"
2931
30-
# Make a GET request (including multiple Accept types) to retrieve the Docker-Content-Digest header
31-
# We use '-sD -' to capture both headers and body in RAW_RESPONSE
32+
# Make GET request to fetch Docker-Content-Digest header
3233
RAW_RESPONSE=$(curl -sD - \
3334
-H "Authorization: Basic $TOKEN_BASE64" \
34-
-H "Accept: application/vnd.docker.distribution.manifest.list.v2+json, application/vnd.docker.distribution.manifest.v2+json, application/vnd.oci.image.manifest.v1+json, application/vnd.oci.image.index.v1+json" \
35-
"https://ghcr.io/v2/$REPO/flink-jar-runner/manifests/$TAG")
35+
-H "Accept: application/vnd.docker.distribution.manifest.list.v2+json,application/vnd.docker.distribution.manifest.v2+json,application/vnd.oci.image.manifest.v1+json,application/vnd.oci.image.index.v1+json" \
36+
"https://ghcr.io/v2/$REPO/manifests/$TAG")
37+
38+
# Output raw response for debugging
39+
echo "==== RAW RESPONSE START ===="
40+
echo "$RAW_RESPONSE"
41+
echo "==== RAW RESPONSE END ===="
3642
3743
# Separate headers from body
3844
HEADERS=$(echo "$RAW_RESPONSE" | sed -n '/^HTTP/,$p' | sed '/^$/q')
3945
40-
# Extract the Docker-Content-Digest from headers
46+
# Extract Docker-Content-Digest from headers
4147
DIGEST=$(echo "$HEADERS" | awk '/docker-content-digest:/ { print $2 }' | tr -d $'\r')
4248
4349
if [[ -z "$DIGEST" ]]; then
@@ -54,7 +60,7 @@ jobs:
5460
DELETE_STATUS=$(curl -s -o /dev/null -w "%{http_code}" \
5561
-X DELETE \
5662
-H "Authorization: Basic $TOKEN_BASE64" \
57-
"https://ghcr.io/v2/$REPO/flink-jar-runner/manifests/$DIGEST")
63+
"https://ghcr.io/v2/$REPO/manifests/$DIGEST")
5864
5965
if [[ "$DELETE_STATUS" -ge 200 && "$DELETE_STATUS" -lt 300 ]]; then
6066
echo "Image deleted successfully (HTTP $DELETE_STATUS)."

0 commit comments

Comments
 (0)