forked from mediaelch/mediaelch-doc
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathupdate_github_pages.sh
More file actions
executable file
·50 lines (42 loc) · 1.08 KB
/
Copy pathupdate_github_pages.sh
File metadata and controls
executable file
·50 lines (42 loc) · 1.08 KB
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
#!/usr/bin/env bash
set -euo pipefail
IFS=$'\n\t'
BASE_DIR="$( cd "$(dirname "$0")"; pwd -P )"
cd "${BASE_DIR}"
# get a clean master branch assuming
git checkout master
git pull origin master
git clean -df
git checkout -- .
git fetch --all
# build html docs from sphinx files
pushd docs
./create_changelog.sh
pushd source
sphinx-build -b html . "../../_build"
popd
popd
# create or use orphaned gh-pages branch
branch_name=gh-pages
if [ "$(git branch --list "$branch_name")" ]
then
git stash
git checkout $branch_name
git pull origin $branch_name
git checkout stash -- . 2> /dev/null || echo "Nothing on stash stack" # force git stash to overwrite added files
else
git checkout --orphan "$branch_name"
fi
if [ -d "_build" ]
then
(ls | grep -v "_build" | xargs rm -r) || echo "Nothing to clean"
mv _build/* . && rm -rf "_build"
git add .
git commit -m "new pages version $(date)"
git push origin gh-pages
# github.com recognizes gh-pages branch and create pages
# url scheme https//:[github-handle].github.io/[repository]
else
echo "directory _build does not exists"
fi
git checkout master