Skip to content

Deploy Server

Deploy Server #304

Workflow file for this run

name: Deploy Server
concurrency:
group: ${{ github.workflow }}
cancel-in-progress: true
on:
workflow_dispatch:
#push:
jobs:
start-server:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Pull MSSQL container
run: |
docker run --network host -p 1433:1433 -d --name mssql \
-e "ACCEPT_EULA=Y" \
-e "MSSQL_SA_PASSWORD=YourStrong@Passw0rd" \
mcr.microsoft.com/mssql/server:latest
sleep 10
docker exec mssql /opt/mssql-tools18/bin/sqlcmd -S localhost -U sa -P 'YourStrong@Passw0rd' -C -Q "ALTER LOGIN [sa] WITH PASSWORD= '${{ secrets.SQLPASSWORD }}', CHECK_POLICY = OFF"
- name: Setup MSSQL database
run: |
docker cp server/mssql/. mssql:/tmp
docker exec mssql /opt/mssql-tools18/bin/sqlcmd -C -S localhost -U sa -P ${{ secrets.SQLPASSWORD }} -i /tmp/reset.sql
docker exec mssql /opt/mssql-tools18/bin/sqlcmd -C -S localhost -U sa -P ${{ secrets.SQLPASSWORD }} -i /tmp/table.sql
docker exec mssql /opt/mssql-tools18/bin/sqlcmd -C -S localhost -U sa -P ${{ secrets.SQLPASSWORD }} -i /tmp/procedure.sql
docker exec mssql /opt/mssql-tools18/bin/sqlcmd -C -S localhost -U sa -P ${{ secrets.SQLPASSWORD }} -i /tmp/insert.sql
- name: Build Tomcat Docker Image
run: |
mv server/tomcat server/docker/tomcat
docker build -t tomcat:majors_choice server/docker/tomcat
- name: Run Tomcat Docker Container
run: |
docker run --network host -p 8080:8080 -d --name tomcat \
-e "PAYMENT_CODE=${{ secrets.PAYMENT_CODE }}" \
-e "PAYMENT_SECRET=${{ secrets.PAYMENT_SECRET }}" \
-e "SQLPASSWORD=${{ secrets.SQLPASSWORD }}" \
-e "EMAIL_ADDRESS=${{ secrets.EMAIL_ADDRESS }}" \
-e "EMAIL_PASSWORD=${{ secrets.EMAIL_PASSWORD }}" \
-e "GOOGLE_CLIENT_SECRET=${{ secrets.GOOGLE_CLIENT_SECRET }}" \
tomcat:majors_choice
- name: Reverse proxy
run: |
curl -L https://github.com/cloudflare/cloudflared/releases/latest/download/cloudflared-linux-amd64.deb -o cloudflared.deb
sudo dpkg -i cloudflared.deb
cd server/cloudflare
unzip -P "${{ secrets.CLOUDFLARE_ZIP_PASSWORD }}" .cloudflared.zip
mv .cloudflared ~/
cd ~/.cloudflared
sudo mkdir -p /etc/cloudflared
sudo cp * /etc/cloudflared/
sudo cloudflared service install
sudo service cloudflared start
- name: Show tomcat Logs
run: timeout 60m docker logs -f tomcat || true