Skip to content

Commit

Permalink
feat: impl linux build
Browse files Browse the repository at this point in the history
  • Loading branch information
skript023 committed Jul 31, 2024
1 parent 9e2cfec commit 51dba97
Show file tree
Hide file tree
Showing 3 changed files with 95 additions and 35 deletions.
85 changes: 85 additions & 0 deletions .github/workflows/build-linux.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
name: build-linux

on:
push:
branches:
- main # Adjust branch name if necessary
pull_request:
branches:
- main # Adjust branch name if necessary

jobs:
deployment:
name: build-linux
runs-on: ubuntu-latest
permissions: write-all

steps:
- uses: actions/checkout@v3

- name: Install dependencies
run: sudo apt-get update && sudo apt-get install -y build-essential cmake g++ gdb make ninja-build rsync zip

- name: Check CMake version
run: cmake --version

- name: Install Python
uses: actions/setup-python@v2
with:
python-version: '3.x'

- name: Install Conan
run: |
sudo pip install conan==2.2.2
sudo conan config install https://bitbucket.org/telkom-workspace/gaboot-backend/downloads/config_linux.zip
- name: Install Package
run: sudo conan install conanfile.py -of=conan/Linux --build=missing

- name: Echo list of files before removal
run: ls

- name: Remove CMakeUserPresets.json
run: sudo rm CMakeUserPresets.json

- name: Echo list of files after removal
run: ls

- name: Configure CMakeList
run: sudo cmake -D CMAKE_BUILD_TYPE=Release -S. -Bbuild -G Ninja

- name: Build 64bit release Executable
run: |
sudo cmake --build ./build --config Release --target Gaboot --
- name: Check if Executable got built
run: if [ ! -f "build/Gaboot" ]; then exit 1; fi

- name: Move binary to new folder
run: |
sudo mkdir Linux
sudo mkdir Linux/postgres
sudo mkdir Linux/postgres/data
echo "SERVER_KEY=${{ secrets.SERVER_KEY }}" | sudo tee ./Linux/.env
echo "SECRET=${{ secrets.SECRET }}" | sudo tee -a ./Linux/.env
sudo cp -r src/assets Linux/assets
sudo cp config/config.json Linux/config.json
sudo cp config/pg_hba.conf Linux/postgres/data/pg_hba.conf
sudo cp config/supervisord.conf Linux/supervisord.conf
sudo cp Dockerfile Linux/Dockerfile
sudo cp docker-compose.yml Linux/docker-compose.yml
sudo cp build/Gaboot Linux/Gaboot
- name: Zip files
run: sudo zip -r Gaboot.zip Linux/Gaboot Linux/config.json Linux/Dockerfile Linux/docker-compose.yml Linux/supervisord.conf Linux/assets Linux/.env

- name: Upload binary to release
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: ./Gaboot.zip
tag: v1.0.0
asset_name: Gaboot.zip
overwrite: true
body: "Gaboot Release Binary"
repo_name: skript023/Gaboot
41 changes: 7 additions & 34 deletions .github/workflows/deployment.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
name: deploy

on:
push:
branches:
- main # Adjust branch name if necessary
pull_request:
branches:
- main # Adjust branch name if necessary
workflow_dispatch:
# push:
# branches:
# - main # Adjust branch name if necessary
# pull_request:
# branches:
# - main # Adjust branch name if necessary

jobs:
deployment:
Expand Down Expand Up @@ -102,31 +103,3 @@ jobs:
- name: Deploy to docker containers
run: ssh ${{ secrets.SERVER_USER }}@${{ secrets.SERVER_IP }} "cd /home/${{ secrets.SERVER_USER }}/gbt-backend/Linux/ && sudo docker compose up -d --build"

#- name: Build and start Docker containers
# run: |
# ssh ${{ secrets.SERVER_USER }}@${{ secrets.SERVER_IP }} "
# export PGPASSWORD='${{ secrets.DB_PASSWORD }}'
# if sudo docker ps --format '{{.Names}}' | grep -q "gaboot-shop-database"; then
# cd /home/${{ secrets.SERVER_USER }}/gbt-backend/Linux/ && sudo docker compose up -d --build gaboot-api
# cd /home/${{ secrets.SERVER_USER }}/gbt-backend/Linux/ && sudo docker compose restart
# else
# cd /home/${{ secrets.SERVER_USER }}/gbt-backend/Linux/ && sudo docker compose down
# cd /home/${{ secrets.SERVER_USER }}/gbt-backend/Linux/ && sudo docker compose up --build -d
# cd /home/${{ secrets.SERVER_USER }}/gbt-backend/Linux/ && sudo docker cp ../gaboot.sql gaboot-shop-database:/docker-entrypoint-initdb.d/gaboot.sql
# cd /home/${{ secrets.SERVER_USER }}/gbt-backend/Linux/ && sudo docker exec -i gaboot-shop-database psql -U ${{ secrets.DB_USER }} -W ${{ secrets.DB_PASSWORD }} -f docker-entrypoint-initdb.d/gaboot.sql
# fi"

#- name: Connect to PostgreSQL and run SQL query
# run: |
# ssh ${{ secrets.SERVER_USER }}@${{ secrets.SERVER_IP }} export PGPASSWORD="${{ secrets.DB_PASSWORD }}"
# ssh ${{ secrets.SERVER_USER }}@${{ secrets.SERVER_IP }} output=$(sudo psql -h localhost -p 5433 -U ${{ secrets.DB_USER }} -W ${{ secrets.DB_PASSWORD }} -c "SELECT EXISTS (SELECT 1 FROM information_schema.tables WHERE table_schema = 'public' AND table_name = 'master_users');")
#- name: Load dump sql
# run: |
# ssh ${{ secrets.SERVER_USER }}@${{ secrets.SERVER_IP }} export PGPASSWORD="${{ secrets.DB_PASSWORD }}"
# ssh ${{ secrets.SERVER_USER }}@${{ secrets.SERVER_IP }} "
# cd /home/${{ secrets.SERVER_USER }}/gbt-backend/Linux/ &&
# if [ '$output' == 'f' ]; then
# sudo docker cp ../gaboot.sql gaboot-shop-database:/docker-entrypoint-initdb.d/gaboot.sql
# sudo docker exec -i gaboot-shop-database psql -U ${{ secrets.DB_USER }} -W ${{ secrets.DB_PASSWORD }} -f docker-entrypoint-initdb.d/gaboot.sql
# fi"

4 changes: 3 additions & 1 deletion .github/workflows/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@ on: [push, pull_request]

jobs:
build:
runs-on: windows-2022
name: build
runs-on: windows-2022
permissions: write-all

steps:
- uses: actions/checkout@v3

Expand Down

0 comments on commit 51dba97

Please sign in to comment.