需求
由于目前的所有项目都要进行打包到cdn,且cdn进行部署,同时配置dingding通知
脚本
#!/bin/sh
# 钉钉通知
dingTalk () {
webhook='https://oapi.dingtalk.com/robot/send?access_token=我是token'
curl $webhook -H 'Content-Type: application/json' -d "
{
'msgtype': 'text',
'text': {
'content': '项目: System\n${1}\n'
}
}"
}
fileExistDeleted () {
filename="$1"
if [ -d $filename ];
then {
rm -rf $filename
echo "[删除文件成功: $filename]"
}
else
echo "[未检测到包含文件: $filename]"
fi
}
build() {
filename="./static-result"
fileExistDeleted $filename
# 执行编译
npm run build
echo "自动编译完成..."
# 编译后上传文件
qsuits -ak=puNSHQflTC*****EST9at88_yzAwOHslNBhHT5 -process=qupload -path=./dist/static -bucket=trmk-app -rm-prefix=./dist/static -add-prefix=static
# 通知完成
echo "Success"
# 删除前置文件
fileExistDeleted $filename
filename="./logs"
fileExistDeleted $filename
}
if [ $1 == "pull" ];
then {
git pull origin master && chmod -R 777 ./storage/*
currentLog=`git log -1 --pretty=format:'%s' --abbrev-commit | awk -F ':' '{print" " $0 }'`
dingTalk "部署完成: $currentLog"
}
else
build
git add -A
git commit -m $1
git push origin master
echo "Push 完成 \n"
fi
本文由 邓尘锋 创作,采用 知识共享署名4.0 国际许可协议进行许可
本站文章除注明转载/出处外,均为本站原创或翻译,转载前请务必署名
最后编辑时间为: Jul 28, 2021 at 05:13 pm