@@ -130,29 +130,11 @@ jobs:
130130 # Cleanup temporary Docker tags from GitHub Container Registry
131131 - name : Cleanup temporary Docker tags
132132 if : always() # This ensures the step runs even if previous steps fail
133- run : |
134- # Get the package name without the registry prefix
135- PACKAGE_NAME=$(echo "${{ env.IMAGE_NAME }}" | sed 's/ghcr.io\///')
136-
137- # The package name needs to be URL-encoded for the API
138- # Replace "/" with "%2F"
139- ENCODED_PACKAGE_NAME=$(echo "$PACKAGE_NAME" | sed 's/\//%2F/g')
140-
141- # First, we need to find the ID of the tag
142- RESPONSE=$(curl -s -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
143- -H "Accept: application/vnd.github.v3+json" \
144- "https://api.github.com/orgs/bahnew/packages/container/${ENCODED_PACKAGE_NAME}/versions")
145-
146- # Extract the ID of the version with our temporary tag
147- VERSION_ID=$(echo $RESPONSE | jq -r '.[] | select(.metadata.container.tags[] | contains("scan-${{ github.sha }}")) | .id')
148-
149- if [ -n "$VERSION_ID" ]; then
150- # Delete just this specific tag (not the entire version)
151- curl -X DELETE \
152- -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
153- -H "Accept: application/vnd.github.v3+json" \
154- "https://api.github.com/orgs/bahnew/packages/container/${ENCODED_PACKAGE_NAME}/versions/${VERSION_ID}"
155- echo "Deleted temporary tag: scan-${{ github.sha }}"
156- else
157- echo "Could not find version ID for tag: scan-${{ github.sha }}"
158- fi
133+ uses : actions/delete-package-versions@v5
134+ with :
135+ package-name : ' clinical-frontend'
136+ package-type : ' container'
137+ owner : ' bahnew'
138+ token : ${{ secrets.GITHUB_TOKEN }}
139+ min-versions-to-keep : 0
140+ ignore-versions : ' ^(?!scan-${{ github.sha }}$).*$'
0 commit comments