-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcli
executable file
·37 lines (30 loc) · 933 Bytes
/
cli
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
#!/usr/bin/env bash
set -euo pipefail
export DOCKER_DEFAULT_PLATFORM=linux/amd64
reconcile_tool() {
NAME=${1:?"Tool name is required"}
FORCE=${2:-""}
echo "Reconciling ${NAME}..."
NEW_VERSION=$(cat "./${NAME}/version")
IMAGE_NAME="shopstic/${NAME}:${NEW_VERSION}"
if docker manifest inspect "${IMAGE_NAME}" > /dev/null 2>&1; then
if [[ "${FORCE}" != "force" ]]; then
echo "No need to update ${IMAGE_NAME}"
exit 0
fi
fi
echo "Updating ${NAME} to ${NEW_VERSION}"
cd "./${NAME}"
export DOCKER_BUILDKIT=1
docker build \
--build-arg "PACKAGE_VERSION=${NEW_VERSION}" \
-t "${IMAGE_NAME}" .
docker push "${IMAGE_NAME}"
}
reconcile() {
PARALLELISM=${1:-"6"}
find . -maxdepth 1 -type d -not -path . -not -name ".*" -exec test -e "{}/version" ';' -print | \
xargs -I '{}' basename "{}" | \
parallel --tagstring="[{}]" -N1 -j"${PARALLELISM}" ./cli reconcile_tool {}
}
"$@"