@echo off
|
REM 定义变量
|
set REPO_URL=http://shenwc:123456@dh.leon056.com:7499/r/Embedded/HomeAssistantPtoject.git
|
set CLONE_DIR=temp_repo
|
set TARGET_DIR=_book_contents
|
set REMOTE_USER=webuser
|
set REMOTE_PWD=WebUse1r
|
set REMOTE_HOST=data.m-iot.tech
|
set REMOTE_PORT=62182
|
set REMOTE_DIR=/www/wwwroot/192.168.1.5_86
|
|
REM 检查temp_repo目录是否存在,存在则删除
|
if exist %CLONE_DIR% (
|
echo Deleting existing temporary directory...
|
rmdir /S /Q %CLONE_DIR%
|
)
|
|
REM 克隆仓库到临时目录
|
echo Cloning the repository...
|
git clone %REPO_URL% %CLONE_DIR%
|
|
REM 检查克隆是否成功
|
if errorlevel 1 (
|
echo Failed to clone the repository.
|
exit /b 1
|
)
|
|
REM 进入克隆的目录并切换到main分支
|
cd %CLONE_DIR%
|
git checkout main
|
|
REM 检查checkout是否成功
|
if errorlevel 1 (
|
echo Failed to checkout the main branch.
|
exit /b 1
|
)
|
|
REM 复制/docs/_book/目录下的内容到目标目录
|
if not exist ..\%TARGET_DIR% (
|
mkdir ..\%TARGET_DIR%
|
)
|
|
echo Copying files from /docs/_book/...
|
xcopy /E /I /Y docs\_book\* ..\%TARGET_DIR%
|
|
REM 使用 SCP 将内容上传到远程服务器
|
REM 确保目标目录存在并且用户有权限
|
REM 使用 StrictHostKeyChecking=no 自动接受主机密钥,注意安全性
|
cd ..
|
"scp" -P %REMOTE_PORT% -o StrictHostKeyChecking=no -r %TARGET_DIR%\* %REMOTE_USER%@%REMOTE_HOST%:%REMOTE_DIR%
|
|
REM 检查SCP命令的执行结果
|
if errorlevel 1 (
|
echo Failed to upload files to the remote server.
|
exit /b 1
|
)
|
|
REM 清理临时克隆的仓库
|
rmdir /S /Q %CLONE_DIR%
|
|
echo Done!
|