Files
new-site/deploy.bat

74 lines
1.9 KiB
Batchfile
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
@echo off
REM ======================================
REM 毕业设计网站部署脚本 - Windows版本
REM 目标: https://solarark.net/g2026/g4/
REM ======================================
echo.
echo ======================================
echo 毕业设计网站部署脚本
echo 目标: https://solarark.net/g2026/g4/
echo ======================================
echo.
REM 检查 Git 是否安装
where git >nul 2>nul
if %ERRORLEVEL% NEQ 0 (
echo [错误] 未检测到 Git请先安装 Git
echo 下载地址: https://git-scm.com/download/win
pause
exit /b 1
)
REM 设置变量
set REPO_URL=https://gitea.solarark.net/yangyuqing/new-site.git
set BRANCH=master
set DEPLOY_DIR=%CD%\deploy_temp
echo [1/5] 准备部署目录...
if exist "%DEPLOY_DIR%" rmdir /s /q "%DEPLOY_DIR%"
mkdir "%DEPLOY_DIR%"
echo [2/5] 克隆仓库...
cd "%DEPLOY_DIR%"
git clone %REPO_URL% . --branch %BRANCH% --depth 1
if %ERRORLEVEL% NEQ 0 (
echo [错误] 克隆失败,请检查网络连接和凭据
pause
exit /b 1
)
echo [3/5] 验证文件...
if not exist "index.html" (
echo [错误] index.html 不存在,部署失败
pause
exit /b 1
)
echo [4/5] 创建部署包...
cd ..
set TIMESTAMP=%date:~0,4%%date:~5,2%%date:~8,2%_%time:~0,2%%time:~3,2%%time:~6,2%
set ZIP_FILE=website_deploy_%TIMESTAMP%.zip
REM 使用 PowerShell 压缩文件
powershell -Command "Compress-Archive -Path '%DEPLOY_DIR%\*' -DestinationPath '%ZIP_FILE%' -Force"
echo [5/5] 清理临时文件...
rmdir /s /q "%DEPLOY_DIR%"
echo.
echo ======================================
echo ✅ 部署包已创建!
echo 文件: %ZIP_FILE%
echo ======================================
echo.
echo 下一步操作:
echo 1. 使用 FTP/SFTP 工具连接到 solarark.net
echo 2. 上传 %ZIP_FILE% 到服务器
echo 3. 在服务器上解压到 /g2026/g4/ 目录
echo 4. 访问 https://solarark.net/g2026/g4/ 测试
echo.
pause