Skip to content

Commit 61b146f

Browse files
authored
Create push_doc.sh
1 parent 5a766de commit 61b146f

File tree

1 file changed

+53
-0
lines changed

1 file changed

+53
-0
lines changed

ci_scripts/push_doc.sh

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
#!/bin/bash
2+
# This script is meant to be called in the "deploy" step defined in
3+
# circle.yml. See https://circleci.com/docs/ for more details.
4+
# The behavior of the script is controlled by environment variable defined
5+
# in the circle.yml in the top level folder of the project.
6+
7+
MSG="Pushing the docs for revision for branch: $CIRCLE_BRANCH, commit $CIRCLE_SHA1"
8+
9+
cd $HOME
10+
# Copy the build docs to a temporary folder
11+
rm -rf tmp
12+
mkdir tmp
13+
cp -R $HOME/$DOC_REPO/doc/_build/html/* ./tmp/
14+
15+
# Clone the docs repo if it isnt already there
16+
if [ ! -d $DOC_REPO ];
17+
then git clone "[email protected]:$USERNAME/"$DOC_REPO".git";
18+
fi
19+
20+
cd $DOC_REPO
21+
git branch gh-pages
22+
git checkout -f gh-pages
23+
git reset --hard origin/gh-pages
24+
git clean -dfx
25+
26+
for name in $(ls -A $HOME/$DOC_REPO); do
27+
case $name in
28+
.nojekyll) # So that github does not build this as a Jekyll website.
29+
;;
30+
circle.yml) # Config so that build gh-pages branch.
31+
;;
32+
*)
33+
git rm -rf $name
34+
;;
35+
esac
36+
done
37+
38+
# Copy the new build docs
39+
mkdir $DOC_URL
40+
cp -R $HOME/tmp/* ./$DOC_URL/
41+
42+
git config --global user.email $EMAIL
43+
git config --global user.name $USERNAME
44+
git add -f ./$DOC_URL/
45+
git commit -m "$MSG"
46+
git push -f origin gh-pages
47+
if [ $? -ne 0 ]; then
48+
echo "Pushing docs failed"
49+
echo
50+
exit 1
51+
fi
52+
53+
echo $MSG

0 commit comments

Comments
 (0)