-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.sh
64 lines (47 loc) · 1.21 KB
/
build.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
#! /bin/bash
# Shell script to automate build pipeline stuff
echo "Running build"
git checkout react-source
git pull origin react-source
npm install
npm run build
git checkout master
CURRENT_BUILD="$(($(head -n 1 current_build.txt) + 1))"
echo "$CURRENT_BUILD" > 'current_build.txt'
# build/{month}-{day}-{year}/{build-number}
DATE=$(date +"%m-%d-%Y")
BRANCH_NAME="build/${DATE}/$CURRENT_BUILD"
echo "checking out new build branch: $BRANCH_NAME"
git checkout -b "$BRANCH_NAME"
declare -a arr=(
"asset-manifest.json"
"index.html"
"favicon.ico"
"logo512.png"
"logo192.png"
"manifest.json"
"robots.txt"
)
for i in "${arr[@]}"
do
echo "deleting $i"
rm "$i"
done
echo "Removing existing static dir"
rm -r static/
# move all files in build one level up
echo "Copying files from new build"
cd build && mv static ../ && mv * ../
echo "Success"
# move back to top level and remove empty build dir
echo "Removing build"
cd ../ && rmdir build
# Add files, commit, and push to branch
echo "Adding files and building commit"
git add .
COMMIT_MSG=Build
git commit -m "Build#$CURRENT_BUILD $DATE"
echo "Pushing commit to origin $BRANCH_NAME"
git push origin "$BRANCH_NAME"
echo "Success... exiting"
exit 0