-
Notifications
You must be signed in to change notification settings - Fork 0
/
deploy.bat
47 lines (36 loc) · 1.19 KB
/
deploy.bat
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
@echo off
:: Batch script to deploy gh-pages branch to GitHub Pages
:: Configurations
set REPO_URL=https://github.com/evanwporter/Sloth.git
set DOCS_DIR=docs
set BUILD_DIR=%DOCS_DIR%/build
set SPHINX_BUILD_COMMAND=sphinx-build -b html %DOCS_DIR%/source %BUILD_DIR% -E
:: Check if on gh-pages branch
echo Checking current branch...
git rev-parse --abbrev-ref HEAD
if not "%ERRORLEVEL%"=="0" goto error
for /f "tokens=*" %%i in ('git rev-parse --abbrev-ref HEAD') do set BRANCH_NAME=%%i
if not "%BRANCH_NAME%"=="gh-pages" (
echo You are not on the gh-pages branch.
echo Please switch to the gh-pages branch and run this script again.
goto end
)
:: Build the Sphinx documentation
echo Building Sphinx documentation...
%SPHINX_BUILD_COMMAND%
if not "%ERRORLEVEL%"=="0" goto error
:: Commit the changes
echo Adding and committing changes...
git add %BUILD_DIR%/*
git commit -m "Update GitHub Pages"
if not "%ERRORLEVEL%"=="0" goto error
:: Push to gh-pages branch
echo Pushing to gh-pages branch...
git push origin gh-pages
if not "%ERRORLEVEL%"=="0" goto error
echo Deployment to GitHub Pages successful!
goto end
:error
echo An error occurred. Please check the output above for more details.
:end
pause