-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgo
executable file
·51 lines (41 loc) · 1.07 KB
/
go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!/bin/bash
set -e
set -o nounset
set -o pipefail
SCRIPT_DIR=$(cd "$(dirname "$0")" ; pwd -P)
# shellcheck source=./go.variables
source "${SCRIPT_DIR}/go.variables"
goal_containerize() {
docker build . -t "${IMAGE_NAME}"
}
goal_test-container() {
(cd fixture && docker build --build-arg IMAGE_NAME=$IMAGE_NAME . -f Dockerfile.test -t "${IMAGE_NAME}-test")
bundle install
bundle exec rubocop
bundle exec rspec spec
}
goal_publish() {
docker tag "${IMAGE_NAME}" "${IMAGE_NAME}:${TAG}"
docker push "${IMAGE_NAME}:${TAG}"
}
validate-args() {
acceptable_args="$(declare -F | sed -n "s/declare -f goal_//p" | tr '\n' ' ')"
if [[ -z $1 ]]; then
echo "usage: $0 <goal>"
# shellcheck disable=SC2059
printf "\n$(declare -F | sed -n "s/declare -f goal_/ - /p")"
exit 1
fi
if [[ ! " $acceptable_args " =~ .*\ $1\ .* ]]; then
echo "Invalid argument: $1"
# shellcheck disable=SC2059
printf "\n$(declare -F | sed -n "s/declare -f goal_/ - /p")"
exit 1
fi
}
CMD=${1:-}
shift || true
if validate-args "${CMD}"; then
"goal_${CMD}"
exit 0
fi