-
Notifications
You must be signed in to change notification settings - Fork 488
/
deploy-doc.sh
executable file
·62 lines (46 loc) · 1.33 KB
/
deploy-doc.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
61
62
#!/bin/bash
# Exit the script if a command fails
set -e
function info {
echo "[-] $1"
}
function help {
info "Usage: $ deploy-doc.sh <commit message>"
info "Example:"
info " $ deploy-doc.sh \"Deploy documentation to gh-pages\""
}
if [ "$1" == "-h" ] ; then
help
exit 0
fi
gitmessage="${1:-Deploy documentation to gh-pages}"
cwd=$(pwd)
project_name=${PWD##*/}
info "Deloying the documentation to the GH pages from $cwd (project name is $project_name)"
info "Building documentation..."
npm run demo:build:prod
info "Copying the doc folder to /tmp"
rm -rf /tmp/angular-datatables-demo
cp -r dist/demo /tmp/angular-datatables-demo
cd /tmp/angular-datatables-demo
info "Copying project to /tmp and switch to gh-pages branch"
rm -rf /tmp/$project_name
cp -r $cwd /tmp
cd /tmp/$project_name
git add -A && git stash
git checkout gh-pages
git fetch && git reset --hard origin/gh-pages
info "Remove all files except .git"
rm -rf * .angular .vscode
info "Copy the doc to the gh-pages branch"
cp -r /tmp/angular-datatables-demo/* /tmp/$project_name
info "Commit gh-pages"
cd /tmp/$project_name
git add -A && git commit -m "$gitmessage"
info "Pushing to remote"
git push -u origin gh-pages
info "Removing tmp folders"
rm -rf /tmp/$project_name
rm -rf /tmp/angular-datatables-demo
info "Github Pages deployed SUCCESSFULLY!!!"
exit 0