Skip to content

Commit

Permalink
Merge branch 'be/main' into be/develop
Browse files Browse the repository at this point in the history
  • Loading branch information
Chocochip101 committed Jul 19, 2024
2 parents 54ab8f7 + a5f57ed commit 0a5f17f
Showing 1 changed file with 64 additions and 0 deletions.
64 changes: 64 additions & 0 deletions .github/workflows/cd-be-dev-deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
name: Build and Deploy

on:
workflow_dispatch:
push:
branches: be/main

jobs:
build:
runs-on: ubuntu-latest

steps:
- name: Checkout Repository
uses: actions/checkout@v4

- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'

- name: Build project using Gradle
run: ./gradlew clean bootJar

- name: Upload build artifact
uses: actions/upload-artifact@v3
with:
name: cruru-be-develop-jar
path: build/libs/cruru-0.0.1-SNAPSHOT.jar

deploy:
runs-on: self-hosted
needs: build

steps:
- name: Download build artifact
uses: actions/download-artifact@v3
with:
name: cruru-be-develop-jar
path: ./build/libs

- name: Check if room-esc server is running on port 8080
id: check-server-on-port
run: |
echo "Checking if port 8080 is in use..."
PID=$(lsof -t -i:8080 || true)
if [ -n "$PID" ]; then
echo "server_running=true" >> $GITHUB_ENV
echo "PID=$PID" >> $GITHUB_ENV
else
echo "server_running=false" >> $GITHUB_ENV
fi
- name: Stop server if running
if: env.server_running == 'true'
run: |
echo "Stopping server running on port 8080..."
kill -9 $PID
echo "Preivous running Server stopped."
- name: Start server
run: |
sudo nohup java -jar build/libs/cruru-0.0.1-SNAPSHOT.jar &
echo "Lastest Backend API Server started."

0 comments on commit 0a5f17f

Please sign in to comment.