-
Notifications
You must be signed in to change notification settings - Fork 1
/
codeship_deploy.sh
executable file
·30 lines (28 loc) · 1.69 KB
/
codeship_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
# Environment Variables
# key value
# GH_PAGES_BRANCH gh-pages
# CUSTOM_DOAMIN uhfun.cn
# GH_USER_EMAIL [email protected]
# GH_USER_NAME uhfun
# GH_PAGES_REPOSITORY Uhfun-Jekyll
# master
echo '添加posts分支内文章' && cd .. && git clone -b _posts [email protected]:${CI_REPO_NAME}.git _posts && ls _posts && mv _posts/*.md clone/_posts
echo '下载github pages 静态资源' && cd clone && git clone -b ${GH_PAGES_BRANCH} [email protected]:${CI_REPO_NAME}.git _site
echo '删除除.git 外所有文件' && rm -rf _site/**/* || exit 0
echo '重新编译生成静态文件' && bundle install && bundle exec jekyll build
cd _site && echo '自定义域名' && echo ${CUSTOM_DOAMIN} > CNAME
git config --global user.email ${GH_USER_EMAIL}
git config --global user.name ${GH_USER_NAME}
git add .
git commit -m "Commit ${CI_COMMIT_ID} ${CI_COMMIT_MESSAGE} to branch ${GH_PAGES_BRANCH}" && git push origin ${GH_PAGES_BRANCH}
#_posts
cd .. && echo '下载github pages 源文件' && git clone -b master [email protected]:${CI_REPO_NAME}.git _source && cd _source
echo '添加posts分支内文章' && mv ../clone/* _posts
echo '下载github pages 静态资源' && git clone -b ${GH_PAGES_BRANCH} [email protected]:${CI_REPO_NAME}.git _site
echo '删除除.git 外所有文件' && rm -rf _site/**/* || exit 0
echo '重新编译生成静态文件' && bundle install && bundle exec jekyll build
cd _site && echo '自定义域名' && echo ${CUSTOM_DOAMIN} > CNAME
git config --global user.email ${GH_USER_EMAIL}
git config --global user.name ${GH_USER_NAME}
git add .
git commit -m "Commit ${CI_COMMIT_ID} ${CI_COMMIT_MESSAGE} to branch ${GH_PAGES_BRANCH}" && git push origin ${GH_PAGES_BRANCH}