-
Notifications
You must be signed in to change notification settings - Fork 0
/
deploy.sh
52 lines (40 loc) · 1.21 KB
/
deploy.sh
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
# run: . deploy.sh
# if permission denied, run chmod +x deploy.sh
# validate input
extension=${1:($(echo -n ${1} | wc -m) - 4):$(echo -n ${1} | wc -m)}
# https://stackoverflow.com/questions/22179405/bash-script-error-unary-operator-expected
if [ "${1}" == "" ] || [ "${2}" == "" ]; then
echo Usage: ". deploy.sh <name-of-zip> <destination-dir-name>"
kill -INT $$
elif [ "${extension}" != ".zip" ]; then
echo Error: must input .zip file
kill -INT $$
elif [ "${2}" != "fa20" ] && [ "${2}" != "fa20-csm" ]; then
echo Error: destination directory must be "fa20" or "fa20-csm"
kill -INT $$
fi
PROMPT="Do you really want to copy and push ${1}? (y/n): "
echo "${PROMPT}"
read RESPONSE
RESPONSE=$(echo "${RESPONSE}" | tr '[:upper:]' '[:lower:]')
while [ "${RESPONSE}" != "y" ] && [ "${RESPONSE}" != "n" ]
do
echo "${PROMPT}"
read RESPONSE
RESPONSE=$(echo "${RESPONSE}" | tr '[:upper:]' '[:lower:]')
done
if [ "${RESPONSE}" == "n" ]; then
echo Exiting
kill -INT $$
fi
OK_DIR=`pwd`
src="${OK_DIR}/zips/${1}"
REPO_DIR=${WEBSITE_DIR}
dest="${REPO_DIR}assets/${2}"
cp -a ${src} ${dest}
GIT=`which git`
cd ${REPO_DIR}
${GIT} add assets/${2}/${1}
${GIT} commit -m "release ${1}"
${GIT} push ${WEBSITE_PUSH}
cd ${OK_DIR}