-
Notifications
You must be signed in to change notification settings - Fork 5
/
deploy.sh
executable file
·36 lines (30 loc) · 992 Bytes
/
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
GIT_COMMITTER_NAME=$(git config user.name)
GIT_COMMITTER_EMAIL=$(git config user.email)
BUILD_DIR=build
BUILD_BRANCH=build_$(date +%Y-%m-%d_%H-%M-%S)
PUBLISH_BRANCH=${BUILD_BRANCH}_gh-pages
function prepare_build {
git checkout -q master && \
git pull -q origin master && \
rm -rf ${BUILD_DIR}
}
function build_in_a_new_branch {
git checkout -q -B ${BUILD_BRANCH} && \
middleman build && \
git add --force ${BUILD_DIR} && \
git commit -q --no-gpg-sign --message "Middleman build $(date +'%Y-%m-%d %H:%M:%S')"
}
function publish_build_directory {
git subtree split --prefix ${BUILD_DIR} --branch ${PUBLISH_BRANCH} && \
git push -q --force origin ${PUBLISH_BRANCH}:gh-pages
}
function cleanup {
git checkout -q master && \
git branch -q -D ${BUILD_BRANCH} ${PUBLISH_BRANCH} && \
rm -rf ${BUILD_DIR}
}
prepare_build && \
build_in_a_new_branch && \
publish_build_directory && \
cleanup && \
echo "Middleman site built and published 🚀"