Forest_Client/Tool/BuildTool/upload_to_server.sh

47 lines
1.2 KiB
Bash
Raw Normal View History

2024-06-12 15:01:54 +08:00
##!/bin/bash
SHELL_DIR=$(dirname $0)
echo "change dir to $SHELL_DIR"
cd "$SHELL_DIR"
# Source the local environment
if [ -f ./local_env.sh ]; then
source ./local_env.sh
echo "found the local_env file"
fi
VERSION="$1"
PLATFORM="$2"
WORKSPACE="$3"
# Set remote server details (modify as needed)
REMOTE_USER="root"
REMOTE_HOST="132.232.113.98"
REMOTE_PATH="/var/www/html/nld/$WORKSPACE/$PLATFORM/$VERSION"
echo "remote path : $REMOTE_PATH"
# Set remote Build Path (local) (modify as needed)
BUILD_PATH="../../ProjectNLD/ServerData/$PLATFORM/"
# Set the URL where you want to send the message
NOTE_URL="https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=3c92758c-1128-4931-ac8d-f19669d7befe"
tar -czvf upload.tgz -C "$BUILD_PATH" .
ssh "$REMOTE_USER@$REMOTE_HOST" "mkdir -p $REMOTE_PATH"
scp upload.tgz "$REMOTE_USER@$REMOTE_HOST:$REMOTE_PATH"
ssh "$REMOTE_USER@$REMOTE_HOST" "cd $REMOTE_PATH;tar -xzvf upload.tgz;rm -rf upload.tgz"
upload_result=$?
if [ $upload_result -eq 0 ]; then
echo "Build uploaded to remote server successfully."
else
sh to_inner_wechat_robot.sh "$PLATFORM】【$VERSION】【$PROFILE】Failed to upload build to remote server! "
echo "Failed to upload build to remote server."
fi
rm -rf upload.tgz