-
Notifications
You must be signed in to change notification settings - Fork 17
/
deploy.sh
executable file
·61 lines (51 loc) · 1.64 KB
/
deploy.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
#!/bin/bash
set -e
shopt -s extglob
TEMP_DIR="$HOME/vw_website_tmp"
if [ ! -z "$(git status --porcelain)" ]; then
echo "Working directory is not clean"
git status --porcelain
exit 1
fi
mkdir -p ${TEMP_DIR}
if [ ! -z "$(ls -A ${TEMP_DIR})" ]; then
echo "${TEMP_DIR} is not empty"
exit 1
fi
git fetch origin
commits_local_but_not_remote_master=$(git log master..origin/master --oneline)
commits_remote_but_not_local_master=$(git log origin/master..master --oneline)
commits_local_but_not_remote_source=$(git log source..origin/source --oneline)
commits_remote_but_not_local_source=$(git log origin/source..source --oneline)
if [[ "${commits_local_but_not_remote_master}" != "" ]] ; then
echo "commits_local_but_not_remote_master"
exit 1
fi
if [[ "${commits_remote_but_not_local_master}" != "" ]] ; then
echo "commits_remote_but_not_local_master"
exit 1
fi
if [[ "${commits_local_but_not_remote_source}" != "" ]] ; then
echo "commits_local_but_not_remote_source"
exit 1
fi
if [[ "${commits_remote_but_not_local_source}" != "" ]] ; then
echo "commits_remote_but_not_local_source"
exit 1
fi
git checkout "source"
bundle exec jekyll build
cp -r _site/* ${TEMP_DIR}
SOURCE_COMMIT=$(git rev-parse HEAD)
git checkout master
rm -vr !(".git"|".nojekyll"|".pipelines"|"CNAME"|"LICENSE")
cp -r ${TEMP_DIR}/* .
rm -vr .sass-cache
git add --all
git commit -m "Deploy commit ${SOURCE_COMMIT}"
DEPLOY_COMMIT=$(git rev-parse HEAD)
git checkout "source"
echo "Deploy commit created: ${DEPLOY_COMMIT}"
git show ${DEPLOY_COMMIT} --stat
echo "To push changes run: git push origin master"
echo "To view changes run: git checkout master && python -m http.server"