-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild-and-push
More file actions
executable file
·43 lines (34 loc) · 884 Bytes
/
build-and-push
File metadata and controls
executable file
·43 lines (34 loc) · 884 Bytes
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
#!/bin/bash
set -eu
files=(*/Dockerfile)
echo_exec() (
echo "$@"
exec "$@"
)
gha_cache="url_v2=$ACTIONS_RESULTS_URL,token=$ACTIONS_RUNTIME_TOKEN"
build-and-push() (
image=$(dirname $1)
cd "$image"
tag="wint/$image:latest"
if [[ ",$SKIP_CACHE," = *",$image,"* ]] || [[ "$SKIP_CACHE" = "all" ]]; then
nocache_opts=(--no-cache)
else
nocache_opts=()
fi
echo "::group::$tag"
printf '>>>>>>>>>>>>>>>>>>>>>>>>>> building and pushing %s <<<<<<<<<<<<<<<<<<<<<<<<<<\n' "$tag"
echo_exec docker buildx build \
--pull \
--push \
"--cache-from=type=gha,scope=$image,$gha_cache" \
"--cache-to=type=gha,mode=max,scope=$image,$gha_cache" \
"${nocache_opts[@]}" \
--platform linux/amd64,linux/arm64 \
--sbom=false --provenance=false \
-t "$tag" \
.
echo "::endgroup::"
)
for f in "${files[@]}"; do
build-and-push "$f"
done