-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.sh
executable file
·43 lines (31 loc) · 1.14 KB
/
main.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
#!/usr/bin/env bash
BUILD_ID=$1
SCREENSHOT_IDS=$2
NEW_BRANCH=$3
ACCESS_TOKEN=$4
BUILD_INFO=$(node /home/shoov/build_info.js $BUILD_ID $ACCESS_TOKEN)
# Get the values from the JSON and trim the qoute (") signs.
OWNER=$(echo $BUILD_INFO | jq '.owner' | cut -d '"' -f 2)
REPO=$(echo $BUILD_INFO | jq '.repo' | cut -d '"' -f 2)
BRANCH=$(echo $BUILD_INFO | jq '.branch' | cut -d '"' -f 2)
# Clone repo
mkdir clone
git config --global user.email "[email protected]"
git config --global user.name "Robot"
# Setup hub
node /home/shoov/get_hub.js $ACCESS_TOKEN
# Clone repo
cd clone
git config --global hub.protocol https
hub clone --branch=$BRANCH --depth=1 --quiet $OWNER/$REPO .
git checkout -b $NEW_BRANCH
# Download images
node /home/shoov/download_images.js $SCREENSHOT_IDS $ACCESS_TOKEN
# Push new branch
git add --all
git commit -am "New files"
hub push --set-upstream origin $NEW_BRANCH
# Open Pull request
PR=$(hub pull-request -m "Update baseline from branch $BRANCH" -b $OWNER:$BRANCH -h $OWNER:$NEW_BRANCH)
# Send back the pull request info to the build
curl -X PATCH $BACKEND_URL/api/builds/$BUILD_ID?access_token=$ACCESS_TOKEN -d "pull_request=$PR"