#!/usr/bin/env bash # # Run scripts/build-and-push.sh once per service listed in a project file. # Continues after a failure and prints a summary when the batch finishes. # # The list path is required (--services). Relative service paths are resolved # against the directory that contains that file, not the caller's cwd. set -euo pipefail IFS=$'\n\t' readonly SCRIPT_DIR="$(cd "$(dirname "$(readlink -f "$0")")" && pwd)" readonly BUILD_SCRIPT="${SCRIPT_DIR}/build-and-push.sh" SERVICES_FILE="" REMOTE="" forward_args=() # ---------- logging ---------- if [[ -t 1 ]]; then readonly C_INFO=$'\033[0;36m' readonly C_OK=$'\033[0;32m' readonly C_WARN=$'\033[0;33m' readonly C_ERR=$'\033[0;31m' readonly C_RESET=$'\033[0m' else readonly C_INFO="" C_OK="" C_WARN="" C_ERR="" C_RESET="" fi log() { printf '%s[INFO]%s %s\n' "$C_INFO" "$C_RESET" "$*"; } ok() { printf '%s[OK]%s %s\n' "$C_OK" "$C_RESET" "$*"; } warn() { printf '%s[WARN]%s %s\n' "$C_WARN" "$C_RESET" "$*" >&2; } err() { printf '%s[ERROR]%s %s\n' "$C_ERR" "$C_RESET" "$*" >&2; } die() { err "$*"; exit 1; } on_error() { local exit_code=$? err "Script aborted on line ${BASH_LINENO[0]} (exit ${exit_code})." exit "$exit_code" } trap on_error ERR # ---------- helpers ---------- usage() { cat <