-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdeploy-app.sh
More file actions
executable file
·52 lines (44 loc) · 1.38 KB
/
deploy-app.sh
File metadata and controls
executable file
·52 lines (44 loc) · 1.38 KB
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
workspace=("web-app")
mainBranch="master"
productionBranch="production"
watchedArr=("deploy-app.sh" "mobile-app/" "functions/")
changesArr=()
# check working directory is clean
if [ -z "$(git status --porcelain)" ]; then
echo "Working directory is clean... 👍"
else
>&2 echo "Working directory must be clean. Stash or commit changes."
exit 1
fi
# get user confirmation
read -p "Are you sure you want to deploy to $productionBranch? (y/N): " confirm;
if [[ $confirm != [yY] ]] && [[ $confirm != [yY][eE][sS] ]]; then
>&2 echo "Exiting... "
exit 1
fi
echo "Deploying new production version..."
# DEPLOY TO PRODUCTION
# switch to $productionBranch branch and merge changes
git checkout $productionBranch
git merge $mainBranch --no-commit
# check for changes to $watched
for watched in ${watchedArr[@]}
do
if [[ ! -z "$(git status -- $watched | grep $watched)" ]]; then changesArr+=(true);
else changesArr+=(false); fi
done
# commit merge
git commit -am "Merge branch '$mainBranch' into $productionBranch"
# build, commit and push changes
npm run build
git commit -am "build"
git push
# switch back to $mainBranch branch
git checkout $mainBranch
# print out useful links and messages
echo "\n\n"
for index in ${!changesArr[@]}
do
if [ ${changesArr[$index]} == true ]; then echo "✅ Changes made to '"${watchedArr[index]}"'";
else echo "❌ No changes made to '"${watchedArr[index]}"'"; fi
done