mirror of
https://github.com/avatao-content/test-tutorial-framework
synced 2024-11-14 21:57:17 +00:00
62 lines
1.8 KiB
Bash
Executable File
62 lines
1.8 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
set -eu
|
|
set -o pipefail
|
|
set -o errtrace
|
|
shopt -s expand_aliases
|
|
[ "$(uname)" == "Darwin" ] && alias readlink="greadlink" && alias grep="ggrep" || :
|
|
|
|
SCRIPT_DIR="$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")"
|
|
TFW_PATH="${TFW_PATH:-$SCRIPT_DIR/../..}"
|
|
|
|
BASEIMAGE_REPO="${BASEIMAGE_REPO:-baseimage-tutorial-framework}"
|
|
CHALLENGE_REPO="${CHALLENGE_REPO:-"$(basename "$(realpath "${SCRIPT_DIR}/..")")"}"
|
|
FRONTEND_REPO="${FRONTEND_REPO:-frontend-tutorial-framework}"
|
|
|
|
BASEIMAGE_PATH="${TFW_PATH}/${BASEIMAGE_REPO}"
|
|
CHALLENGE_PATH="${TFW_PATH}/${CHALLENGE_REPO}"
|
|
FRONTEND_PATH="${TFW_PATH}/${FRONTEND_REPO}"
|
|
|
|
source "${SCRIPT_DIR}/libhack/baseimage.sh"
|
|
source "${SCRIPT_DIR}/libhack/challenge.sh"
|
|
source "${SCRIPT_DIR}/libhack/frontend.sh"
|
|
|
|
|
|
case ${1:-} in
|
|
start)
|
|
baseimage::build_if_exists
|
|
challenge::build
|
|
challenge::run ${@:2}
|
|
;;
|
|
run)
|
|
challenge:run ${@:2}
|
|
;;
|
|
build-baseimage)
|
|
baseimage::build_if_exists
|
|
;;
|
|
build)
|
|
baseimage::build_if_exists
|
|
challenge::build_no_cache
|
|
;;
|
|
build-frontend)
|
|
frontend::assert_exists
|
|
frontend::build
|
|
;;
|
|
release-baseimage)
|
|
baseimage::assert_exists
|
|
baseimage::release
|
|
;;
|
|
release-frontend)
|
|
frontend::assert_exists
|
|
frontend::release
|
|
;;
|
|
*)
|
|
echo "Usage: tfw.sh [COMMAND]"
|
|
echo " |--- start: build & run TFW challenge"
|
|
echo " |--- run: run TFW challenge"
|
|
echo " |--- build-baseimage: build TFW baseimage"
|
|
echo " |--- build: build TFW baseimage and challenge"
|
|
echo " |--- release-baseimage: tag TFW baseimage and push to DockerHub"
|
|
echo " |--- release-frontend: tag TFW frontend and push to DockerHub"
|
|
;;
|
|
esac
|