-
Notifications
You must be signed in to change notification settings - Fork 23
/
update.sh
executable file
·87 lines (68 loc) · 1.6 KB
/
update.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
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
#!/bin/bash
# Github Credentials
if [ -z $GH_USER ]; then
echo "Set environment variable GH_USER to a valid Github username."
exit 1
fi
if [ -z $GH_PASS ]; then
echo "Set environment variable GH_PASS to a valid Github account's password."
exit 1
fi
WORKSPACE_DIR="workspace"
DUMPS_DIR="dumps"
DUMPS_DIR_PATH=$WORKSPACE_DIR/$DUMPS_DIR
# Change directory to project's root
pushd $1
# Create workspace dir if does not exist
if [ ! -d $WORKSPACE_DIR ]; then
mkdir $WORKSPACE_DIR
fi
# Create dumps dir if does not exist
if [ ! -d $DUMPS_DIR_PATH ]; then
mkdir $DUMPS_DIR_PATH
fi
# Get project name from repo url
function get_project_name {
# $1 - the string to perform split on
index=0
split_arr[0]=""
for i in $(echo "$1" | tr "/" " "); do
split_arr[$index]=$i
index=$((index+1))
done
echo ${split_arr[$((index-1))]}
}
# parse projects
function parse_project {
repo=$1
name=`get_project_name $repo`
pushd $WORKSPACE_DIR
if [ -d $name ]; then
pushd $name
git pull
popd
else
git clone $repo
fi
popd
python testsparser.py $WORKSPACE_DIR/$name > "$DUMPS_DIR_PATH/$name.json"
}
for repo in `cat repos.txt`
do
parse_project $repo
done
git checkout gh-pages
git rebase master
cp -rvf $DUMPS_DIR_PATH/* $DUMPS_DIR
git add dumps/* && git commit -m "dump on `date`"
git checkout master
git push -f https://$GH_USER:$GH_PASS@github.com/vaidik/mozwebqa-dashboard.git gh-pages
if [ $? -eq 0 ]; then
RET_VAL=0
else
RET_VAL=1
fi
echo "PUSHED"
# Go back to the directory you came from
popd
exit $RET_VAL