-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathentrypoint.sh
More file actions
executable file
·80 lines (73 loc) · 1.77 KB
/
entrypoint.sh
File metadata and controls
executable file
·80 lines (73 loc) · 1.77 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#!/bin/sh
set -ex;
image=$1
report=$2
patched_tag=$3
timeout=$4
connection_format=$5
format=$6
output_file=$7
max_retries=${8:-0}
# parse image into image name
image_no_tag=$(echo "$image" | cut -d':' -f1)
# check if output_file has been set
if [ -z "$output_file" ]
then
output=""
else
output="--format $format --output ./data/$output_file"
fi
# check selected method of buildkit connection
case "$connection_format" in
# through a buildx instance
"buildx")
docker buildx create --name=copa-action
docker buildx use --default copa-action
connection="--addr buildx://copa-action"
;;
# through a running buildkit container over tcp
"buildkit-container")
connection="--addr tcp://127.0.0.1:8888"
;;
# through the default docker buildkit endpoint enabled with a custom socket
"custom-socket")
connection=""
;;
esac
patch_image() {
if copa patch -i "$image" -r ./data/"$report" -t "$patched_tag" $connection --timeout $timeout $output
then
patched_image="$image_no_tag:$patched_tag"
echo "patched-image=$patched_image" >> "$GITHUB_OUTPUT"
return 0
else
return 1
fi
}
# run copa to patch image
if [ "$max_retries" -eq 0 ]
then
if ! patch_image
then
echo "Error patching image $image with copa"
exit 1
fi
else
retries=0
while [ "$retries" -lt "$max_retries" ]
do
if patch_image
then
break
else
retries=$((retries + 1))
if [ "$retries" -eq "$max_retries" ]
then
echo "Error patching image $image with copa"
exit 1
else
echo "WARNING: Attempt $retries failed. Retrying..."
fi
fi
done
fi