-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpublish.bat
More file actions
96 lines (81 loc) · 2.66 KB
/
Copy pathpublish.bat
File metadata and controls
96 lines (81 loc) · 2.66 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
@echo off
setlocal
echo ========================================
echo Bridgeframe Toolkit - Publish to GitHub
echo ========================================
echo.
cd /d "%~dp0"
set "SOURCE=%~dp0"
set "GDRIVE_DEST=G:\My Drive\Intersect_Collaborations_LLC\04_projects\Bridgeframe-Toolkit"
REM Get timestamp using PowerShell
for /f %%i in ('powershell -NoProfile -Command "Get-Date -Format yyyyMMdd_HHmm"') do set "TIMESTAMP=%%i"
set "ZIP_NAME=Bridgeframe-Toolkit_%TIMESTAMP%.zip"
set "ZIP_PATH=%TEMP%\%ZIP_NAME%"
set "FINAL_PATH=%GDRIVE_DEST%\%ZIP_NAME%"
echo [1/3] Backing up project to Google Drive...
echo.
echo Timestamp: %TIMESTAMP%
echo Source: %SOURCE%
echo Destination: %GDRIVE_DEST%
echo ZIP File: %ZIP_NAME%
echo.
if not exist "%GDRIVE_DEST%" (
echo ERROR: Google Drive destination does not exist: %GDRIVE_DEST%
echo Please ensure Google Drive is mounted and the folder exists.
pause
exit /b 1
)
if exist "%ZIP_PATH%" del "%ZIP_PATH%"
echo Creating ZIP archive...
echo This may take a few minutes...
echo.
REM Use git to list tracked and untracked files respecting .gitignore, then zip them
REM This includes communications/ (which is in .gitignore but we want it backed up)
REM Uses -z flag to handle filenames with special characters
pushd "%SOURCE%" >nul
powershell -NoProfile -Command "$gitFiles = (git ls-files --cached --others --exclude-standard -z) -split \"`0\" | Where-Object { $_ }; $commFiles = Get-ChildItem -Path 'communications' -Recurse -File -ErrorAction SilentlyContinue | Resolve-Path -Relative | ForEach-Object { $_ -replace '^\.\\','' }; ($gitFiles + $commFiles) | Sort-Object -Unique | Where-Object { $_ -and (Test-Path -LiteralPath $_) } | tar.exe -a -c -f '%ZIP_PATH%' -T -"
popd >nul
if not exist "%ZIP_PATH%" (
echo ERROR: ZIP file was not created.
pause
exit /b 1
)
for %%A in ("%ZIP_PATH%") do set "ZIP_SIZE=%%~zA"
set /a ZIP_SIZE_MB=%ZIP_SIZE%/1048576
echo ZIP file size: %ZIP_SIZE_MB% MB
echo.
echo Copying to Google Drive...
copy /Y "%ZIP_PATH%" "%FINAL_PATH%"
if %ERRORLEVEL% neq 0 (
echo.
echo ERROR: Backup to Google Drive failed.
pause
exit /b 1
)
del "%ZIP_PATH%"
echo Backup complete: %FINAL_PATH%
echo.
echo [2/3] Rendering the book...
quarto render
if %errorlevel% neq 0 (
echo.
echo ERROR: Quarto render failed.
pause
exit /b 1
)
echo.
echo [3/3] Publishing to GitHub Pages...
quarto publish gh-pages --no-prompt
if %errorlevel% neq 0 (
echo.
echo ERROR: GitHub publish failed.
pause
exit /b 1
)
echo.
echo ========================================
echo Success! Book published to GitHub Pages
echo Backup saved to Google Drive
echo ========================================
echo.
pause