2024-02-26 21:34:06 +00:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
|
|
|
function error_handler() {
|
|
|
|
echo >&2 "Exited with BAD EXIT CODE '${2}' in ${0} script at line: ${1}."
|
|
|
|
exit "$2"
|
|
|
|
}
|
|
|
|
trap 'error_handler ${LINENO} $?' ERR
|
|
|
|
set -o errtrace -o errexit -o nounset -o pipefail
|
|
|
|
|
|
|
|
if [[ -z "${SPIFFWORKFLOW_BACKEND_GIT_PUBLISH_CLONE_URL:-}" ]]; then
|
|
|
|
echo >&2 "ERROR: SPIFFWORKFLOW_BACKEND_GIT_PUBLISH_CLONE_URL must be specified to clone the git repo."
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [[ -z "${SPIFFWORKFLOW_BACKEND_GIT_SOURCE_BRANCH:-}" ]]; then
|
|
|
|
echo >&2 "ERROR: SPIFFWORKFLOW_BACKEND_GIT_SOURCE_BRANCH must be specified to clone the git repo."
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [[ -z "${SPIFFWORKFLOW_BACKEND_BPMN_SPEC_ABSOLUTE_DIR:-}" ]]; then
|
|
|
|
echo >&2 "ERROR: SPIFFWORKFLOW_BACKEND_BPMN_SPEC_ABSOLUTE_DIR must be specified to clone the git repo."
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [[ -n "${SPIFFWORKFLOW_BACKEND_GIT_SSH_PRIVATE_KEY:-}" ]]; then
|
|
|
|
if [[ -z "${SPIFFWORKFLOW_BACKEND_GIT_SSH_PRIVATE_KEY_PATH:-}" ]]; then
|
|
|
|
export SPIFFWORKFLOW_BACKEND_GIT_SSH_PRIVATE_KEY_PATH=$(mktemp /tmp/ssh_private_key.XXXXXX)
|
|
|
|
fi
|
|
|
|
chmod 600 "${SPIFFWORKFLOW_BACKEND_GIT_SSH_PRIVATE_KEY_PATH}"
|
|
|
|
echo "${SPIFFWORKFLOW_BACKEND_GIT_SSH_PRIVATE_KEY}" >"${SPIFFWORKFLOW_BACKEND_GIT_SSH_PRIVATE_KEY_PATH}"
|
|
|
|
fi
|
|
|
|
|
2024-02-28 15:35:35 +00:00
|
|
|
# otherwise git clone will not clone since the directory is not empty
|
|
|
|
if [[ -d "${SPIFFWORKFLOW_BACKEND_BPMN_SPEC_ABSOLUTE_DIR}/lost+found" ]]; then
|
|
|
|
rm -r "${SPIFFWORKFLOW_BACKEND_BPMN_SPEC_ABSOLUTE_DIR}/lost+found"
|
|
|
|
fi
|
|
|
|
|
2024-02-28 16:07:29 +00:00
|
|
|
export GIT_SSH_COMMAND="ssh -F /dev/null -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -i ${SPIFFWORKFLOW_BACKEND_GIT_SSH_PRIVATE_KEY_PATH}"
|
2024-02-26 21:34:06 +00:00
|
|
|
git clone -b "$SPIFFWORKFLOW_BACKEND_GIT_SOURCE_BRANCH" "$SPIFFWORKFLOW_BACKEND_GIT_PUBLISH_CLONE_URL" "$SPIFFWORKFLOW_BACKEND_BPMN_SPEC_ABSOLUTE_DIR"
|