buildkit/hack/build_ci_first_pass

60 lines
1.6 KiB
Plaintext
Raw Normal View History

#!/usr/bin/env bash
TYP=$1
. $(dirname $0)/util
set -e
usage() {
echo "usage: ./hack/build_ci_first_pass <binaries|integration-tests>"
exit 1
}
if [ -z "$TYP" ]; then
usage
fi
importCacheFlags=""
exportCacheFlags=""
exportFlags=""
if [ "$TRAVIS" = "true" ]; then
if [ -z "$TRAVIS_COMMIT" ]; then
echo "Travis commit required"
exit 0
fi
if [ -f /tmp/buildkit-ci-cache-repo ]; then
exportCacheFlags="--cache-to=type=inline"
exportFlags="--output=type=image,push=true,name=$(cat /tmp/buildkit-ci-cache-repo)"
fi
if [ "$TYP" = "binaries" ]; then
importCacheFlags="--cache-from=type=registry,ref=cicache.buildk.it/moby/buildkit/master:binaries --cache-from=type=registry,ref=cicache.buildk.it/moby/buildkit/master:integration-tests"
exportFlags="$exportFlags:binaries"
elif [ "$TYP" = "integration-tests" ]; then
importCacheFlags="--cache-from=type=registry,ref=cicache.buildk.it/moby/buildkit/master:integration-tests"
exportFlags="$exportFlags:integration-tests"
fi
elif [ "$GITHUB_ACTIONS" = "true" ]; then
if [ -n "$cacheref" ]; then
importCacheFlags="--cache-from=type=local,src=$cacheref"
exportCacheFlags="--cache-to=type=local,dest=$cacheref"
fi
fi
case $TYP in
"binaries")
buildxCmd build $importCacheFlags $exportCacheFlags $exportFlags \
--target "binaries" \
$currentcontext
;;
"integration-tests")
buildxCmd build $importCacheFlags $exportCacheFlags $exportFlags \
--target "integration-tests-base" \
$currentcontext
;;
*)
echo >&2 "Unknown type $TYP"
exit 1
;;
esac