-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathupdate-json-index.sh
62 lines (49 loc) · 1.72 KB
/
update-json-index.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
echo -e "Starting to update json-index\n"
#copy new files
echo -e "Copy new files"
cp -R collections $HOME/collections
cp buildCSV.R $HOME/.
#go to home and setup git
cd $HOME
git config --global user.email "[email protected]"
git config --global user.name "Travis"
#using token clone gh-pages branch
git clone --quiet --branch=gh-pages https://${GH_TOKEN}@github.com/iDigBio/idb-us-collections.git gh-pages > /dev/null
echo -e "Clone gh-pages repo"
#go into directory and create our index file
cd gh-pages/
rm -rf collections/
mkdir collections
cp -R $HOME/collections/* collections/
cd collections
sed -s '$a,' * > ../collections.json
sed -i '$ d' ../collections.json
sed -i '1i [' ../collections.json
sed -i '$a ]' ../collections.json
#add, commit and push files
git add --all :/
git commit -m "Travis build $TRAVIS_BUILD_NUMBER pushed to gh-pages"
git push -fq origin gh-pages > /dev/null
#using token clone json-index branch
cd $HOME
git clone --quiet --branch=json-index https://${GH_TOKEN}@github.com/iDigBio/idb-us-collections.git json-index > /dev/null
echo -e "Clone json-index repo"
#go into directory and create our index file
cd json-index/
mkdir collections
cd collections
cp -R $HOME/collections/* .
sed -s '$a,' * > ../collections.json
sed -i '$ d' ../collections.json
sed -i '1i [' ../collections.json
sed -i '$a ]' ../collections.json
cd ..
rm -rf collections/
cp $HOME/buildCSV.R .
Rscript buildCSV.R
rm -rf buildCSV.R
#add, commit and push files
git add --all
git commit -m "Travis build $TRAVIS_BUILD_NUMBER pushed to json-index"
git push -fq origin json-index > /dev/null
echo -e "Done magic with GitHub pages\n"