Repository navigation
Expand file tree
/
Copy pathpublish.bat
More file actions
77 lines (65 loc) · 1.43 KB
/
Copy pathpublish.bat
File metadata and controls
77 lines (65 loc) · 1.43 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
@echo off
setlocal
cd /d "%~dp0"
if /I "%~1"=="--help" goto help
if /I "%~1"=="-h" goto help
where git >nul 2>nul
if errorlevel 1 (
echo Git was not found. Please install Git or add it to PATH.
exit /b 1
)
where npm.cmd >nul 2>nul
if errorlevel 1 (
echo npm.cmd was not found. Please install Node.js or add it to PATH.
exit /b 1
)
echo.
echo [1/4] Building site...
set ASTRO_TELEMETRY_DISABLED=1
call npm.cmd run build
if errorlevel 1 (
echo.
echo Build failed. Nothing was committed.
exit /b 1
)
echo.
echo [2/4] Staging changes...
git status --short
git add -A
git diff --cached --quiet
if not errorlevel 1 (
echo.
echo No changes to commit.
exit /b 0
)
set "commit_msg=%*"
if not defined commit_msg (
for /f %%i in ('powershell -NoProfile -Command "Get-Date -Format yyyy-MM-dd-HHmmss"') do set "stamp=%%i"
set "commit_msg=Update site content %stamp%"
)
echo.
echo [3/4] Committing changes...
git commit -m "%commit_msg%"
if errorlevel 1 (
echo.
echo Commit failed.
exit /b 1
)
echo.
echo [4/4] Pushing to GitHub...
git push origin HEAD
if errorlevel 1 (
echo.
echo Push failed. The commit was created locally but was not uploaded.
exit /b 1
)
echo.
echo Done. GitHub Actions will deploy the site after the push.
exit /b 0
:help
echo Usage:
echo publish.bat
echo publish.bat "Your commit message"
echo.
echo The script builds the site, stages all changes, commits them, and pushes the current branch.
exit /b 0