-
Notifications
You must be signed in to change notification settings - Fork 65
/
Copy path.gh-pages-update.sh
executable file
·60 lines (54 loc) · 1.28 KB
/
.gh-pages-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
#!/bin/bash
GH_REPO="@github.com/Rapporter/pander.git"
FULL_REPO="https://$GH_TOKEN$GH_REPO"
mkdir out
cd out
git init
git remote add origin $FULL_REPO
git fetch
git config user.name "rapporter-travis"
git config user.email "travis"
# handle master
git checkout master
CHANGED_FILES=`git show --stat $TRAVIS_COMMIT`
echo -e "\nChanged files:\n\n$CHANGED_FILES\n\n"
# check if vignettes were updated
if [[ $CHANGED_FILES =~ .*vignettes.*\.Rmd.* ]]
then
echo "Updating vignettes..."
R -e 'devtools::install_github("rstudio/rmarkdown"); devtools::build_vignettes()'
rm -f inst/doc/*.R
git add inst/doc
fi
# check if readme was update
if [[ $CHANGED_FILES =~ .*README\.brew.* ]]
then
echo "Updating README..."
R -f ../.brewer.R
git add README.md
fi
git commit -m "Update by travis after $TRAVIS_COMMIT"
git push origin master
cd ../
git pull origin master
rm -rf out
mkdir out
cd out
git init
git remote add origin $FULL_REPO
git fetch
git config user.name "rapporter-travis"
git config user.email "travis"
# gh-pages handling
git checkout gh-pages
for files in '../inst/doc/*.html'; do
cp $files .
done
if [[ $CHANGED_FILES =~ .*\.brew.* ]]
then
R -f ../.brewer.R
fi
git add .
git reset README.md
git commit -m "GH-Pages update by travis after $TRAVIS_COMMIT"
git push origin gh-pages