6
6
#
7
7
# Usage: export QDRANT_VERSION="ghcr/dev" && ./prepare_image.sh
8
8
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
+ }
9
25
10
26
QDRANT_VERSION=${QDRANT_VERSION:- " ghcr/dev" }
11
27
@@ -15,6 +31,7 @@ EVENT_TYPE="benchmark-trigger-image-build"
15
31
16
32
if [[ -z " ${BEARER_TOKEN} " ]]; then
17
33
echo " BEARER_TOKEN is not set. Exiting."
34
+ cancel_github_workflow
18
35
exit 1
19
36
fi
20
37
@@ -34,6 +51,7 @@ if [[ ${QDRANT_VERSION} == docker/* ]] || [[ ${QDRANT_VERSION} == ghcr/* ]]; the
34
51
fi
35
52
else
36
53
echo " Error: unknown version ${QDRANT_VERSION} . Version name should start with 'docker/' or 'ghcr/'"
54
+ cancel_github_workflow
37
55
exit 1
38
56
fi
39
57
48
66
49
67
if [[ " ${CONTAINER_REGISTRY} " == " docker.io" ]]; then
50
68
echo " Impossible to push the image to Docker Container Registry in this workflow."
69
+ cancel_github_workflow
51
70
exit 1
52
71
fi
53
72
@@ -65,6 +84,7 @@ counter=0
65
84
while ! docker manifest inspect " $IMAGE " > /dev/null 2>&1 ; do
66
85
if [ $counter -ge $MAX_RETRIES ]; then
67
86
echo " Reached maximum retries. Exiting."
87
+ cancel_github_workflow
68
88
exit 2
69
89
fi
70
90
# sleep for 10 minutes, in seconds
0 commit comments