-
Notifications
You must be signed in to change notification settings - Fork 2
/
process_pull_requests.sh
executable file
·58 lines (34 loc) · 1.18 KB
/
process_pull_requests.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
#!/bin/sh
USER="wdecoste"
REPO="kitchensink-example"
OPENSHIFT_GIT="ssh://[email protected]/~/git/demo.git/"
SOURCE_GIT="https://github.com/wdecoste/kitchensink-example.git"
APP_NAME="demo"
KEY="[OPENSHIFT]"
PULL_FILE="/mnt/extra/demo_pull.txt"
pulls=`wget -q -O - "https://api.github.com/repos/${USER}/${REPO}/pulls"`
#echo "${pulls}"
#echo "----------------------------------------"
max=$(<${PULL_FILE})
echo "${max}"
title=`echo "${pulls}" | jsawk 'return this.title'`
echo "${title}"
if [[ ${title} == *${KEY}* ]]
then
pull=`echo "${pulls}" | jsawk 'return this.number' | cut -d'[' -f 2 | cut -d']' -f 1`
echo "${pull}"
if [[ ${pull} > ${max} ]]
then
git clone ${OPENSHIFT_GIT} /mnt/extra/tmp/${APP_NAME}
cd /mnt/extra/tmp/${APP_NAME}
git remote add upstream ${SOURCE_GIT}
sed -i 's/\/upstream\/*/\/upstream\/*\n\tfetch = +refs\/pull\/*\/head:refs\/pull\/upstream\//g' /mnt/extra/tmp/${APP_NAME}/.git/config
git fetch upstream
git checkout -b ${pull} pull/upstream/${pull}
git checkout master
git merge ${pull} -m "test"
git push
echo "${pull}" > "${PULL_FILE}"
fi
fi
rm -rf /mnt/extra/tmp/${APP_NAME}