#!/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
CUR_HOST=$(echo $HOSTNAME | cut -d "." -f 1)

if [[ "$CUR_HOST" != "alchemy" ]]; then
    echo "HOST ${CUR_HOST} is not alchemy!"
    exit 1
fi

rm -rf node_modules && pnpm install
npm run build:huiwing

sudo cp -r ./dist/* $openresty_html_dir

SERVER=${1:-1}

# upload to upyun
cd cdn
sh upload_assets.sh .huiwing_upyun_pass $SERVER

