-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.sh
More file actions
91 lines (74 loc) · 2.45 KB
/
script.sh
File metadata and controls
91 lines (74 loc) · 2.45 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
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
#!/bin/bash
reposLocation="$HOME/Developer/social-novapro"
# reposLocation="~/git/social-media"
# cd "$reposLocation"
# follow name of repo
repos=("social-backend" "social-frontend-plain")
# repos=("https://github.com/social-novapro/social-backend" "https://github.com/social-novapro/social-frontend-plain")
currentCommits=()
cloneRepos() {
for repo in ${repos[@]}
do
cd ./repos
git clone $repo
done
}
currentCommits() {
for (( i=1; i<=${#repos[@]}; i++ ))
do
cd "${reposLocation}/${repos[i-1]}"
currentCommits[i]=$(git rev-parse HEAD)
echo "Current commit for ${repos[i-1]}: ${currentCommits[i]}"
done
}
programLoop() {
while true
do
checkForCommits
sleep 5
done
}
checkForCommits() {
for (( i=1; i<=${#repos[@]}; i++ ))
do
cd "${reposLocation}/${repos[i-1]}"
latest_commit=$(git rev-parse HEAD)
last_commit=${currentCommits[i]}
if [ "$latest_commit" != "$last_commit" ]
then
echo "New commit detected! ${repos[i-1]} : ${latest_commit} vs ${last_commit}"
echo "Pulling latest changes"
git pull
echo "Building"
if [ "${repos[i-1]}" == "social-backend" ]
then
echo "Building backend"
cd "${reposLocation}/${repos[i-1]}"
npm install
docker build -t novapro/interact_api .
# docker tag novapro/interact_api registry.xnet.com:5000/novapro/interact_api:latest
# docker push registry.xnet.com:5000/novapro/interact_api
docker run -p 5002:5002 --name interact_api -d novapro/interact_api
else
echo "Building frontend"
cd "${reposLocation}/${repos[i-1]}"
docker build -t novapro/interact .
# docker tag novapro/interact registry.xnet.com:5000/novapro/interact:latest
# docker push registry.xnet.com:5000/novapro/interact
docker run -p 5500:433 --name interact -d novapro/interact
fi
currentCommits[i]=$(git rev-parse HEAD)
# Code to update your application goes here
else
echo "No new commits ${repos[i-1]} : ${latest_commit}"
fi
done
}
currentCommits
sleep 5
programLoop
# for i in "${!repos[@]}"
# do
# currentCommits+=("${commitMessages[i]// /$'\n'}")
# done
# Get the hash of the last commit