-
Notifications
You must be signed in to change notification settings - Fork 0
/
gh-pages.sh
executable file
·55 lines (46 loc) · 1.1 KB
/
gh-pages.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
#!/usr/bin/env bash
#This script publishes the current p
DIR=${PWD##*/}
GH_DIR="../subschema-gh-pages"
GH_REPO="[email protected]:subschema/subschema.github.io.git"
GH_BRANCH="master"
OPWD=$PWD
HASH=
function check(){
echo "Check"
open $GH_DIR/index.html &
}
function push(){
echo "Pushing"
cd $GH_DIR && \
git add -A && \
git commit -a -m "Updated hash ${HASH}" && \
git push origin $GH_BRANCH && \
echo "$GH_BRANCH now running $HASH "
}
function build(){
echo "Building"
cd $OPWD && \
rm -rf .build && \
npm run demo && \
HASH=$(ls ./.build/app.*.js | sed 's,.*app\.\(.*\)\.js,\1,g' )
echo "Using Hash: ${HASH}"
rm $GH_DIR/*
cp ./.build/* $GH_DIR && \
sed "s/\"app\(\.entry\)\{0,1\}\.js\"/\"app.${HASH}.js\"/" ./public/index.html > $GH_DIR/index.html
}
function init_git() {
echo "Initing git"
git clone ${GH_REPO} $GH_DIR
}
function ask() {
read -p "$1 [Y]" dp;
RET=1;
case $dp in
y|Y) RET=0;;
esac
return $RET;
}
[ ! -d $GH_DIR ] && init_git
build && check && ask "Do you want to push" && push || echo "Don't forget to publish";
exit 0;