1
0
mirror of https://github.com/avatao-content/test-tutorial-framework synced 2024-12-05 02:31:33 +00:00
test-tutorial-framework/hack/libhack/frontend.sh
2019-11-07 16:30:54 +01:00

45 lines
1.1 KiB
Bash

# Requires context:
# - FRONTEND_PATH: absolute path of frontend repo
FRONTEND_IMAGE_NAME="${FRONTEND_IMAGE_NAME:-avatao/frontend-tutorial-framework}"
libhack_dir="$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")"
source "${libhack_dir}/common.sh"
frontend::build() {
frontend::assert_exists
pushd "${FRONTEND_PATH}"
docker build -t "${FRONTEND_IMAGE_NAME}:$(releasename)" .
popd
}
frontend::assert_exists() {
if [[ ! -d "${FRONTEND_PATH}" ]]; then
printf "Cannot find frontend at ${FRONTEND_PATH}!\n"
exit 1
fi
}
frontend::release() {
frontend::assert_exists
pushd "${FRONTEND_PATH}"
local tag
tag="$(releasename)"
read -p "Tag and push frontend \"${tag}\"? [y/N]" -r && echo
if [[ $REPLY =~ ^(y|Y|yes|Yes|YES)$ ]]; then
printf "Pushing git tag to upstream...\n"
tag="${tag}" description="${tag}" force_push_tag
printf "\nPushing image to DockerHub...\n"
docker push "${FRONTEND_IMAGE_NAME}:${tag}"
fi
popd
}
frontend::latest_tag() {
frontend::assert_exists
pushd "${FRONTEND_PATH}"
git describe --abbrev=0
popd
}