102 lines
3.2 KiB
Batchfile
102 lines
3.2 KiB
Batchfile
@echo off
|
|
REM ============================================================
|
|
REM Newbury Exhibit -> Gitea uploader
|
|
REM _deploy checkout lives OUTSIDE the project (sibling folder)
|
|
REM so it can never copy into itself (no more nested copies).
|
|
REM Default HTTPS via DNS; auto-fallback to direct LAN.
|
|
REM ============================================================
|
|
setlocal enabledelayedexpansion
|
|
|
|
set GITEA_HOST=gitea.hideawaygaming.com.au
|
|
set LAN_URL=https://gitea.hideawaygaming.com.au
|
|
set OWNER=jessikitty
|
|
set REPO=newbury-exhibit
|
|
set BRANCH=dev
|
|
|
|
REM SRC = this script's folder (the project). Strip trailing backslash.
|
|
set "SRC=%~dp0"
|
|
if "%SRC:~-1%"=="\" set "SRC=%SRC:~0,-1%"
|
|
|
|
REM DEPLOY = sibling folder next to the project, NOT inside it.
|
|
for %%I in ("%SRC%\..") do set "PARENT=%%~fI"
|
|
set "DEPLOY=%PARENT%\newbury-exhibit_deploy"
|
|
|
|
set HTTPS_REMOTE=https://%GITEA_HOST%/%OWNER%/%REPO%.git
|
|
set LAN_REMOTE=%LAN_URL%/%OWNER%/%REPO%.git
|
|
|
|
echo.
|
|
echo === Newbury Exhibit deploy ===
|
|
echo Source: %SRC%
|
|
echo Checkout: %DEPLOY% (sibling - outside the project)
|
|
echo Target: %HTTPS_REMOTE% (branch %BRANCH%)
|
|
echo.
|
|
|
|
REM --- ensure ghost roster is present (copy from NewburyNights if missing) ---
|
|
if not exist "%SRC%\data\ghosts.json" (
|
|
if exist "%PARENT%\NewburyNights\ghosts.enriched.json" (
|
|
echo Copying ghost roster into data\ghosts.json ...
|
|
copy /y "%PARENT%\NewburyNights\ghosts.enriched.json" "%SRC%\data\ghosts.json" >nul
|
|
)
|
|
)
|
|
|
|
REM --- fresh _deploy checkout (clone via HTTPS; fall back to LAN) ---
|
|
if exist "%DEPLOY%" (
|
|
echo Removing old checkout...
|
|
rmdir /s /q "%DEPLOY%"
|
|
)
|
|
echo Cloning %BRANCH% via HTTPS...
|
|
git clone -b %BRANCH% "%HTTPS_REMOTE%" "%DEPLOY%"
|
|
if errorlevel 1 (
|
|
echo HTTPS clone failed, trying direct LAN...
|
|
git clone -b %BRANCH% "%LAN_REMOTE%" "%DEPLOY%"
|
|
if errorlevel 1 ( echo ERROR: clone failed on both remotes. & pause & exit /b 1 )
|
|
)
|
|
|
|
REM --- git identity from global config ---
|
|
for /f "tokens=*" %%a in ('git config --global user.name') do set GITNAME=%%a
|
|
for /f "tokens=*" %%a in ('git config --global user.email') do set GITEMAIL=%%a
|
|
if "!GITNAME!"=="" set GITNAME=jessikitty
|
|
if "!GITEMAIL!"=="" set GITEMAIL=jess.rogerson.29@outlook.com
|
|
|
|
REM --- copy project into checkout. Source has no _deploy inside it now, ---
|
|
REM --- but still exclude the usual noise. .git in DEPLOY is protected. ---
|
|
echo Syncing files...
|
|
robocopy "%SRC%" "%DEPLOY%" /MIR /XD "node_modules" ".git" "newbury-exhibit_deploy" "backups" /XF "*.log" ".run.pid" ".deploy-installed" >nul
|
|
|
|
pushd "%DEPLOY%"
|
|
git config user.name "!GITNAME!"
|
|
git config user.email "!GITEMAIL!"
|
|
git config http.postBuffer 524288000
|
|
git config http.version HTTP/1.1
|
|
|
|
echo.
|
|
echo === Staged changes ===
|
|
git add -A
|
|
git status --short
|
|
echo.
|
|
|
|
set /p MSG="Commit message (blank = 'Update exhibit'): "
|
|
if "!MSG!"=="" set MSG=Update exhibit
|
|
|
|
git commit -m "!MSG!"
|
|
if errorlevel 1 (
|
|
echo Nothing to commit, or commit failed.
|
|
popd & pause & exit /b 0
|
|
)
|
|
|
|
echo.
|
|
echo Pushing via HTTPS...
|
|
git push origin %BRANCH%
|
|
if errorlevel 1 (
|
|
echo HTTPS push failed ^(proxy/500?^). Retrying direct LAN...
|
|
git push "%LAN_REMOTE%" %BRANCH%
|
|
if errorlevel 1 (
|
|
echo ERROR: push failed on both remotes. Commit saved in %DEPLOY%.
|
|
popd & pause & exit /b 1
|
|
)
|
|
)
|
|
echo.
|
|
echo === Pushed to %BRANCH% successfully ===
|
|
popd
|
|
pause
|