This repository has been archived by the owner on Sep 14, 2023. It is now read-only.
forked from willscripted/s3d
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy paths3d
executable file
·95 lines (82 loc) · 1.83 KB
/
s3d
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
#!/usr/bin/env bash
set -e
DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
VERSION=0.1.0
# Colors
GREEN="\033[0;32m"
BLUE="\033[0;34m"
GREY="\033[1;30m"
CYAN="\033[0;36m"
RED="\033[0;31m"
YELLOW="\033[0;33m"
NO_COLOR="\033[0m"
BOLD="\033[1m"
function displayHelpText {
text=$(cat <<-EOF
Usage:
s3d <config-file>
-h, display this message
-f, force upload without asking for confirmation
-e (git_tag|git_sha1|author)=VAL sets path variable to VAL
-v, display version
\n
EOF
)
echo -e "$text"
}
function displayVersionText {
echo -e "s3d version $(cat "$path/version")\n"
}
function confirm {
read -p "Are you sure? " -n 1 -r USER_REPLY
if [[ $USER_REPLY =~ ^[Yy]$ ]]
then
echo ""
else
echo -e "$RED\n\nDeploy aborted\n$NO_COLOR"
exit 1
fi
}
path="$(readlink $DIR/s3d | xargs dirname )"
git_tag=""
git_sha1=""
author=""
while getopts "hvfe:" opt; do
case "$opt" in
h)
displayHelpText
exit 0
;;
v)
displayVersionText
exit 0
;;
f)
ignore_confirm=true
;;
e)
if [[ $OPTARG =~ ^git_tag=(.+)$ ]]; then
git_tag=${BASH_REMATCH[1]}
echo -e "\$git_tag = ${git_tag}"
elif [[ $OPTARG =~ ^git_sha1=(.+)$ ]]; then
git_sha1=${BASH_REMATCH[1]}
echo -e "\$git_sha1 = ${git_sha1}"
elif [[ $OPTARG =~ ^author=(.+)$ ]]; then
author=${BASH_REMATCH[1]}
echo -e "\$author = ${author}"
else
echo "Could not match -e param. Must be of form (git_tag|git_sha1|author)=VAL"
fi
;;
esac
done
shift "$((OPTIND-1))" # Shift off the options
if [ ! $1 ] ; then
displayHelpText
exit 0
fi
$path/scripts/plan.rb "${1}" "${git_tag}" "${git_sha1}" "${author}"
if [ ! $ignore_confirm ] ; then
confirm
fi
$path/scripts/execute.rb "${1}" "${git_tag}" "${git_sha1}" "${author}"