81fe1224df
避免 SSH 非登录环境下 HOSTNAME 为空导致 npm run build: 失败;/bin/sh 下 [[ 不可用。 Made-with: Cursor
29 lines
604 B
Bash
Executable File
29 lines
604 B
Bash
Executable File
#!/bin/sh
|
|
set -x
|
|
|
|
git restore .
|
|
git fetch origin
|
|
git rebase origin/master
|
|
openresty_html_dir='/usr/local/openresty/nginx/html/music-room'
|
|
|
|
mkdir -p $openresty_html_dir
|
|
|
|
# 使用 hostname(非 $HOSTNAME):非登录 SSH 下 HOSTNAME 常为空,会导致误跑成 npm run build:
|
|
CUR_HOST=$(hostname | cut -d. -f1)
|
|
|
|
if [ "$CUR_HOST" != "moicen" ]; then
|
|
echo "HOST ${CUR_HOST} is not moicen!"
|
|
exit 1
|
|
fi
|
|
|
|
rm -rf node_modules && pnpm install
|
|
npm run build:moicen
|
|
|
|
sudo cp -r ./dist/* $openresty_html_dir
|
|
|
|
SERVER=${1:-1}
|
|
|
|
# upload to upyun
|
|
cd cdn
|
|
sh upload_assets.sh .${CUR_HOST}_upyun_pass $SERVER
|