-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdeploy_site.sh
executable file
·55 lines (42 loc) · 1.43 KB
/
deploy_site.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
#!/bin/bash
# This is a manual Maven-site-to-GitHub-project-pages script
#
# It is inspired by the GitHub project X1011/git-directory-deploy
#
# It assumes:
# * You are currently on master
# * All local changes stashed or committed
# * The gh-pages branch exists
# Stop on errors
set -e
# We firgure where to work based on the fact that this script should be in the
# root of the project (next to the pom.xml file)
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
cd "$SCRIPT_DIR"
export WT="$SCRIPT_DIR/target/site"
# Make sure to pull in master
git checkout master
git pull
# Ensure we've previously checked out gh-pages and are up to date
git checkout gh-pages
git pull
# Ensure we're on master for reals - this shouldn't do anything
git checkout master
# Clean target directory and create the site
# Note that we also run package - if we don't, FindBugs and test
# reports won't be available
mvn clean package site
# Ensure we have a site
if [ ! -d "$WT" ]; then
echo "PANIC: Could not find directory $WT"
exit 1
fi
# Our actual work: set up HEAD/index to point to gh-pages and $WT, then
# add/commit/push our site, then reset everything
git symbolic-ref HEAD refs/heads/gh-pages
git --work-tree="$WT" reset --mixed --quiet
git --work-tree="$WT" add --all
git --work-tree="$WT" commit -m "maven site commit $(date) from $(hostname)"
git push origin gh-pages
git symbolic-ref HEAD refs/heads/master
git reset --mixed