From aa03af1faa9f831fa1ea52ea70fb8a09c46f0228 Mon Sep 17 00:00:00 2001 From: jessikitty Date: Sun, 28 Jun 2026 12:55:22 +1000 Subject: [PATCH] Update --- deploy.sh | 33 ++++++++++++++++++++++++++++ push-manual.bat | 25 +++++++++++++++++++++ upload-to-gitea.bat | 53 +++++++++++++++++++++++++++++++++------------ 3 files changed, 97 insertions(+), 14 deletions(-) create mode 100644 deploy.sh create mode 100644 push-manual.bat diff --git a/deploy.sh b/deploy.sh new file mode 100644 index 0000000..cbf4ef8 --- /dev/null +++ b/deploy.sh @@ -0,0 +1,33 @@ +#!/usr/bin/env bash +# Newbury Exhibit — deploy box runner (pull-only, never pushes). +# Forces local working copy to match origin/dev, then (re)starts the server. +set -e + +BRANCH=dev +PORT=${PORT:-34034} + +cd "$(dirname "$0")" + +echo "== Fetching origin/$BRANCH ==" +git fetch origin "$BRANCH" + +echo "== Forcing working copy to origin/$BRANCH (discards any local changes) ==" +git reset --hard "origin/$BRANCH" + +# install deps only if package files changed since last run +if [ package.json -nt .deploy-installed ] || [ package-lock.json -nt .deploy-installed ] || [ ! -f .deploy-installed ]; then + echo "== Installing dependencies ==" + npm install --no-audit --no-fund + touch .deploy-installed +else + echo "== Dependencies unchanged, skipping npm install ==" +fi + +# free the port if something is already on it +if command -v fuser >/dev/null 2>&1; then + fuser -k ${PORT}/tcp 2>/dev/null || true + sleep 1 +fi + +echo "== Starting server on port ${PORT} ==" +PORT=${PORT} npm start diff --git a/push-manual.bat b/push-manual.bat new file mode 100644 index 0000000..549c62a --- /dev/null +++ b/push-manual.bat @@ -0,0 +1,25 @@ +@echo off +REM Manual push helper: pushes whatever is already committed in _deploy. +REM Tries HTTPS first, then direct LAN. Use after a failed push, or to re-push. +setlocal +set OWNER=jessikitty +set REPO=newbury-exhibit +set BRANCH=dev +set LAN_REMOTE=http://10.0.0.55:3000/%OWNER%/%REPO%.git +set SRC=%~dp0 + +if not exist "%SRC%_deploy" ( + echo No _deploy checkout found. Run upload-to-gitea.bat first. + pause & exit /b 1 +) +pushd "%SRC%_deploy" +echo Pushing %BRANCH% via HTTPS... +git push origin %BRANCH% +if errorlevel 1 ( + echo HTTPS failed, trying direct LAN... + git push "%LAN_REMOTE%" %BRANCH% + if errorlevel 1 ( echo ERROR: push failed on both. & popd & pause & exit /b 1 ) +) +echo Done. +popd +pause diff --git a/upload-to-gitea.bat b/upload-to-gitea.bat index 62c6d2c..4065243 100644 --- a/upload-to-gitea.bat +++ b/upload-to-gitea.bat @@ -1,36 +1,42 @@ @echo off REM ============================================================ REM Newbury Exhibit -> Gitea uploader -REM Wipe-and-re-clone _deploy checkout, copy tree, commit, push. -REM Mirrors the newbury-nights deploy pattern. +REM Default: HTTPS via DNS. Auto-fallback: direct LAN (bypasses nginx). +REM Clean re-clone of dev, copy tree, show status, commit, push. REM ============================================================ setlocal enabledelayedexpansion set GITEA_HOST=gitea.hideawaygaming.com.au +set LAN_URL=http://10.0.0.55:3000 set OWNER=jessikitty set REPO=newbury-exhibit set BRANCH=dev set SRC=%~dp0 +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 Target: https://%GITEA_HOST%/%OWNER%/%REPO% (branch %BRANCH%) +echo Target: %HTTPS_REMOTE% (branch %BRANCH%) +echo Fallback: %LAN_REMOTE% echo. -REM --- fresh _deploy checkout --- +REM --- fresh _deploy checkout (clone via HTTPS; fall back to LAN) --- if exist "%SRC%_deploy" ( echo Removing old _deploy checkout... rmdir /s /q "%SRC%_deploy" ) -echo Cloning %BRANCH%... -git clone -b %BRANCH% "https://%GITEA_HOST%/%OWNER%/%REPO%.git" "%SRC%_deploy" +echo Cloning %BRANCH% via HTTPS... +git clone -b %BRANCH% "%HTTPS_REMOTE%" "%SRC%_deploy" if errorlevel 1 ( - echo ERROR: clone failed. Check credentials / branch exists. - pause & exit /b 1 + echo HTTPS clone failed, trying direct LAN... + git clone -b %BRANCH% "%LAN_REMOTE%" "%SRC%_deploy" + if errorlevel 1 ( echo ERROR: clone failed on both remotes. & pause & exit /b 1 ) ) -REM --- auto-detect git identity from existing global config --- +REM --- auto-detect 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 @@ -43,6 +49,9 @@ robocopy "%SRC%." "%SRC%_deploy" /E /XD "_deploy" "node_modules" ".git" /XF "*.l pushd "%SRC%_deploy" git config user.name "!GITNAME!" git config user.email "!GITEMAIL!" +REM larger buffer + HTTP/1.1 makes pushes more robust through a reverse proxy +git config http.postBuffer 524288000 +git config http.version HTTP/1.1 echo. echo === Staged changes === @@ -56,11 +65,27 @@ if "!MSG!"=="" set MSG=Update exhibit git commit -m "!MSG!" if errorlevel 1 ( echo Nothing to commit, or commit failed. -) else ( - git push origin %BRANCH% - if errorlevel 1 ( echo ERROR: push failed. & popd & pause & exit /b 1 ) - echo. - echo === Pushed to %BRANCH% successfully === + popd & pause & exit /b 0 ) + +echo. +echo Pushing via HTTPS... +git push origin %BRANCH% +if errorlevel 1 ( + echo. + echo HTTPS push failed ^(proxy/500?^). Retrying direct LAN: %LAN_REMOTE% + git push "%LAN_REMOTE%" %BRANCH% + if errorlevel 1 ( + echo. + echo ERROR: push failed on both remotes. + echo Your commit is saved in _deploy - you can retry manually: + echo cd "%SRC%_deploy" + echo git push origin %BRANCH% + echo git push "%LAN_REMOTE%" %BRANCH% + popd & pause & exit /b 1 + ) +) +echo. +echo === Pushed to %BRANCH% successfully === popd pause