-
Notifications
You must be signed in to change notification settings - Fork 150
/
sidecar-build-publish.sh
executable file
·39 lines (36 loc) · 1.42 KB
/
sidecar-build-publish.sh
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
#!/bin/bash
#
# Copyright (c) 2020-2021 Red Hat, Inc.
# This program and the accompanying materials are made
# available under the terms of the Eclipse Public License 2.0
# which is available at https://www.eclipse.org/legal/epl-2.0/
#
# SPDX-License-Identifier: EPL-2.0
#
set -e
BUILD_PUBLISH="$1"
BUILD_ARGS="--push"
# shellcheck disable=SC2207
FILES_CHANGED=($(git diff --name-only --diff-filter=d -r "$2" "$3"))
SIDECARS_TO_TEST=()
for file in "${FILES_CHANGED[@]}"
do
if [[ $file == sidecars/* ]]; then
SIDECAR_NAME=$(echo "$file" | cut -d/ -f 2)
# shellcheck disable=SC2199
if ! [[ " ${SIDECARS_TO_TEST[@]} " =~ ${SIDECAR_NAME} ]]; then
SIDECARS_TO_TEST+=("$SIDECAR_NAME")
PLATFORMS=$(cat sidecars/"$SIDECAR_NAME"/PLATFORMS)
SHORT_SHA1=$(git rev-parse --short=7 HEAD)
if [[ $BUILD_PUBLISH == 'build-publish' ]]; then
IMAGE_NAME=quay.io/eclipse/che-plugin-sidecar:"$SIDECAR_NAME"-"$SHORT_SHA1"
echo "Building $IMAGE_NAME"
docker buildx build --provenance=false --platform "$PLATFORMS" -t "$IMAGE_NAME" \
"$BUILD_ARGS" sidecars/"$SIDECAR_NAME"/
elif [[ $BUILD_PUBLISH == 'build' ]]; then
echo "Checking $SIDECAR_NAME-$SHORT_SHA1"
docker buildx build --provenance=false --platform "$PLATFORMS" sidecars/"$SIDECAR_NAME"/
fi
fi
fi
done