Build and Publish Site / docker (push) Successful in 4s
Run `ioc ...` from cicd runner, remove ansible and cli commands Reviewed-on: #71
38 lines
1.2 KiB
Bash
Executable File
38 lines
1.2 KiB
Bash
Executable File
#!/bin/bash
|
|
# Installs the ioc of a service from its deployed ioc dir on /sls.
|
|
# Requires the service to have been deployed first (deploy-and-restart-service.sh),
|
|
# which is what puts the substituted and environment-renamed ioc files in place.
|
|
#
|
|
# Usage: ./.gitea/scripts/ioc-install.sh <service-name> <dev|prod>
|
|
set -euo pipefail
|
|
|
|
source "$(dirname "$0")/common.sh"
|
|
init_service_env "${1:-}" "${2:-}"
|
|
|
|
echo "=========================================="
|
|
echo "Installing ioc: ${IOC_NAME} (${AGEBD_ENV})"
|
|
echo "=========================================="
|
|
|
|
if [ ! -d "${IOC_DIR}" ]; then
|
|
echo "Ioc dir '${IOC_DIR}' not found, deploy the service first" >&2
|
|
exit 1
|
|
fi
|
|
|
|
STDERR_FILE=$(mktemp)
|
|
trap 'rm -f "${STDERR_FILE}"' EXIT
|
|
|
|
set +e
|
|
(cd "${IOC_DIR}" && ioc install -V --facility sls --ioc "${IOC_NAME}" --clean) 2>"${STDERR_FILE}"
|
|
INSTALL_RC=$?
|
|
set -e
|
|
|
|
cat "${STDERR_FILE}" >&2
|
|
|
|
# 'ioc install ...' returns exit code 0 even on failure, so its stderr is
|
|
# inspected for error keywords to force a pipeline failure.
|
|
# Note: -a because some responses of the 'ioc ...' cli are non-utf8.
|
|
if [ ${INSTALL_RC} -ne 0 ] || grep -qa -e "\[error\]" -e "Unable to write" "${STDERR_FILE}"; then
|
|
echo "Failed to install ioc ${IOC_NAME}" >&2
|
|
exit 1
|
|
fi
|