vue shell 自动打包上传cdn脚本

in Shell with 0 comment

需求

由于目前的所有项目都要进行打包到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
Comments are closed.