forked from Rosuav/shed
-
Notifications
You must be signed in to change notification settings - Fork 0
/
publish-gh-pages
executable file
·26 lines (25 loc) · 987 Bytes
/
publish-gh-pages
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
#!/bin/sh
# Deprecated in favour of git-deploy (see also)
# Update your gh-pages branch based on a subdirectory of your main tree
# npm run build || exit $?
# publish-gh-pages
# Should be run on a clean working tree (all changes committed, although
# pushing is optional) with a successful and complete build.
# If your build dir is not build/ in the repo root, select a different
# subtree with: git config push.gh-pages.subtree some/path/to/build
# Do not include a trailing slash.
if ! git rev-parse gh-pages >/dev/null 2>/dev/null
then
git checkout --orphan gh-pages
git rm -rf .
git commit --allow-empty -m "Initialize empty gh-pages"
git checkout master
fi
rev=`git rev-parse --short HEAD`
dir=`git config push.gh-pages.subtree || echo build`
git add -f $dir
tree=`git write-tree --prefix=$dir/`
git reset HEAD $dir
commit=`echo Update gh-pages from $dir $rev|git commit-tree $tree -p gh-pages`
git update-ref refs/heads/gh-pages $commit
git push origin gh-pages:gh-pages