ci: remove test image and then check response (#1037)

This commit is contained in:
Nathan.fooo 2024-12-03 14:58:31 +08:00 committed by GitHub
parent 51bf9a85c7
commit 016c7ed569
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 12 additions and 1 deletions

View File

@ -146,4 +146,15 @@ jobs:
- name: Remove Docker Images from Docker Hub - name: Remove Docker Images from Docker Hub
run: | run: |
TOKEN=$(curl -s -H "Content-Type: application/json" -X POST -d '{"username": "appflowyinc", "password": "${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}"}' https://hub.docker.com/v2/users/login/ | jq -r .token) TOKEN=$(curl -s -H "Content-Type: application/json" -X POST -d '{"username": "appflowyinc", "password": "${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}"}' https://hub.docker.com/v2/users/login/ | jq -r .token)
curl -s -X DELETE -H "Authorization: JWT ${TOKEN}" https://hub.docker.com/v2/repositories/appflowyinc/${{ matrix.test_service }}/tags/${GITHUB_SHA}/ if [ -z "$TOKEN" ]; then
echo "Error: Docker Hub token not set"
exit 1
fi
IMAGE_TAG="${{ matrix.test_service }}"
RESPONSE=$(curl -s -o /dev/null -w "%{http_code}" -X DELETE -H "Authorization: JWT ${TOKEN}" https://hub.docker.com/v2/repositories/appflowyinc/${IMAGE_TAG}/tags/${GITHUB_SHA}/)
if [ "$RESPONSE" -ne 204 ]; then
echo "Error: Failed to delete Docker image tag. HTTP response code: $RESPONSE"
else
echo "Successfully deleted Docker image tag for $IMAGE_TAG:${GITHUB_SHA}"
fi