github actions support

This commit is contained in:
Amit Kumar Nandi 2024-02-16 18:12:18 +05:30
parent d220340cc3
commit 76893cc90f
2 changed files with 23 additions and 39 deletions

View file

@ -1,27 +0,0 @@
set "SQL_FILE_URL=https://github.com/aamitn/URLShortener/raw/master/create.sql"
echo Waiting for MariaDB to start...
timeout /t 1 /nobreak
cd mariadb-11.4.0-winx64/bin
REM Run SQL commands using mysql command-line tool
mysql -u root -p1234qwer -e "CREATE DATABASE IF NOT EXISTS shortener;"
REM Download SQL file
curl -LJO "%SQL_FILE_URL%"
REM Run the SQL script
mysql -u root -p1234qwer < create.sql
mysql -u root -p1234qwer -e "SHOW DATABASES;"
mysql -u root -p1234qwer -e "USE shortener"
mysql -u root -p1234qwer -e "SELECT * FROM shortener;"
REM Optionally, remove the downloaded SQL file
del create.sql
echo Deployed Successfully...
start "" http://localhost:8080
exit /b 0

View file

@ -1,5 +1,4 @@
@echo off
setlocal enabledelayedexpansion
REM Set Tomcat and URL variables
@ -40,15 +39,13 @@ echo Running Tomcat server...
cd "apache-tomcat-%TOMCAT_VERSION%\bin"
call startup.bat
REM Wait for Tomcat to start (adjust sleep time as needed)
timeout /t 30 /nobreak
timeout /t 20 /nobreak
call shutdown.bat
timeout /t 2 /nobreak
call startup.bat
cd ..
cd ..
REM Main Script Execution
if "%OS%"=="Windows_NT" (
call :download_and_install_mariadb
@ -73,19 +70,33 @@ cd mariadb-11.4.0-winx64/bin
cd..
cd..
@echo SET PASSWORD FOR 'root'@'localhost' = PASSWORD('1234qwer');> init.txt
@echo SET PASSWORD FOR 'root'@'localhost' = PASSWORD('1234qwer');> dbinit.txt
REM Get the current directory
set "CURRENT_DIR=%CD%"
REM Create db.bat script for database initialization
echo timeout /t 1 /nobreak > db.bat
echo cd mariadb-11.4.0-winx64/bin >> db.bat
echo mysql -u root -p1234qwer -e "CREATE DATABASE IF NOT EXISTS shortener;" >> db.bat
echo curl -LJO "https://github.com/aamitn/URLShortener/raw/master/create.sql" >> db.bat
echo mysql -u root -p1234qwer ^< create.sql >> db.bat
echo mysql -u root -p1234qwer -e "SHOW DATABASES;" >> db.bat
echo mysql -u root -p1234qwer -e "USE shortener" >> db.bat
echo mysql -u root -p1234qwer -e "SELECT * FROM shortener;" >> db.bat
echo del create.sql >> db.bat
echo echo Deployed Successfully... >> db.bat
echo start "" http://localhost:8080 >> db.bat
echo exit /b 0 >> db.bat
REM Start the db.bat script
start db.bat
REM Navigate to mariadb-11.4.0-winx64/bin
cd mariadb-11.4.0-winx64/bin
REM Initialize DB
call mariadb-install-db.exe
call mariadb-install-db.exe
REM Run MariaDB server with the init file
call mysqld.exe --console --init-file="%CURRENT_DIR%\\init.txt"
call mysqld.exe --console --init-file="%CURRENT_DIR%\\dbinit.txt"