1 Star 0 Fork 0

piao / piao.gitee.io

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
deploy.sh 2.26 KB
一键复制 编辑 原始数据 按行查看 历史
piao 提交于 2022-08-20 18:17 . feat: add iptables picture
#!/bin/sh
#---
#title: "Deploy"
#date: 2020-08-02T16:20:48+08:00
#lastmod: 2020-08-02T23:05:45+08:00
#draft: true
#---
# If a command fails then the deploy stops
set -e
printf "\033[0;32msh ${0} ${1} ${2}...\033[0m\n"
function usage() {
echo "sh ${0} new [xxx.md] # 在post目录创建一篇文章"
echo "sh ${0} run [gitee|github] # 运行 config.toml|config.github.toml 配置"
echo "sh ${0} commit [gitee|github] [commit msg] # Build the project Push to repo"
}
function new() {
if [ -z "${1}" ]; then
echo "invalid name"
exit 1
fi
hugo new post/${1}
}
function gitee() {
PUBLIC=./public
baseURL=https://piao.gitee.io/
repoURL=https://gitee.com/piao/piao.git
userName=piao
userEmail=wangpiaohua@163.com
repoSite=Gitee
config=./config.toml
}
function github() {
PUBLIC=./public_github
baseURL=https://piaohua.github.io/
repo_token=`cat ~/.ssh/github.repo_token`
repoURL=https://${repo_token}@github.com/piaohua/piaohua.github.io.git
# repoURL=https://github.com/piaohua/piaohua.github.io.git
userName=piaohua
userEmail=twopiao7@gmail.com
repoSite=GitHub
config=./config.github.toml
}
function config() {
if [[ "${1}" == "github" ]]; then
github
else
gitee
fi
}
function run() {
config $1
hugo server --theme=even --buildDrafts --config ${config}
}
function commit() {
config $1
printf "\033[0;32mDeploying updates to ${repoSite}...\033[0m\n"
# Build the project.
# hugo -t even # if using a theme, replace with `hugo -t <YOURTHEME>`
hugo --theme=even --baseUrl ${baseURL} --config ${config} -d ${PUBLIC}
# Go To Public folder
cd ${PUBLIC}
# git remote add origin ${repoURL}
# git remote -v
# Add changes to git.
git add .
# Commit changes.
msg="rebuilding site $(date)"
if [ -n "$2" ]; then
msg="$2"
fi
git commit -m "$msg"
# Push to repo
git remote set-url origin ${repoURL}
git config user.name ${userName}
git config user.email ${userEmail}
# Push source and build repos.
git push origin master
}
case $1 in
new)
new $2
;;
run)
run $2
;;
commit)
commit $2 $3
;;
*)
usage
;;
esac
1
https://gitee.com/piao/piao.gitee.io.git
git@gitee.com:piao/piao.gitee.io.git
piao
piao.gitee.io
piao.gitee.io
master

搜索帮助