66#
77# Usage: export QDRANT_VERSION="ghcr/dev" && ./prepare_image.sh
88
9+ cancel_github_workflow () {
10+ echo " Canceling the current GH workflow run..."
11+
12+ RUN_ID=$( curl -s \
13+ -H " Accept: application/vnd.github+json" \
14+ -H " Authorization: Bearer ${BEARER_TOKEN} " \
15+ -H " X-GitHub-Api-Version: 2022-11-28" \
16+ " https://api.github.com/repos/${GITHUB_REPOSITORY} /actions/runs" \
17+ | jq ' .workflow_runs[] | select(.head_branch=="' ${GITHUB_REF# refs/ heads/ } ' ") | .id' | head -n 1)
18+
19+ curl -s \
20+ -X POST \
21+ -H " Accept: application/vnd.github+json" \
22+ -H " Authorization: Bearer ${BEARER_TOKEN} " \
23+ " https://api.github.com/repos/${GITHUB_REPOSITORY} /actions/runs/${RUN_ID} /cancel"
24+ }
925
1026QDRANT_VERSION=${QDRANT_VERSION:- " ghcr/dev" }
1127
@@ -15,6 +31,7 @@ EVENT_TYPE="benchmark-trigger-image-build"
1531
1632if [[ -z " ${BEARER_TOKEN} " ]]; then
1733 echo " BEARER_TOKEN is not set. Exiting."
34+ cancel_github_workflow
1835 exit 1
1936fi
2037
@@ -34,6 +51,7 @@ if [[ ${QDRANT_VERSION} == docker/* ]] || [[ ${QDRANT_VERSION} == ghcr/* ]]; the
3451 fi
3552else
3653 echo " Error: unknown version ${QDRANT_VERSION} . Version name should start with 'docker/' or 'ghcr/'"
54+ cancel_github_workflow
3755 exit 1
3856fi
3957
4866
4967if [[ " ${CONTAINER_REGISTRY} " == " docker.io" ]]; then
5068 echo " Impossible to push the image to Docker Container Registry in this workflow."
69+ cancel_github_workflow
5170 exit 1
5271fi
5372
@@ -65,6 +84,7 @@ counter=0
6584while ! docker manifest inspect " $IMAGE " > /dev/null 2>&1 ; do
6685 if [ $counter -ge $MAX_RETRIES ]; then
6786 echo " Reached maximum retries. Exiting."
87+ cancel_github_workflow
6888 exit 2
6989 fi
7090 # sleep for 10 minutes, in seconds
0 commit comments