From 11222840da63a1479bbb375e8bde8e17cc269acd Mon Sep 17 00:00:00 2001 From: Do Yeop Kim <113661364+Dobby-Kim@users.noreply.github.com> Date: Tue, 16 Jul 2024 13:11:09 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20AWS=20self-hosted=20runner=20=ED=99=98?= =?UTF-8?q?=EA=B2=BD=20=EC=9D=B4=EC=9A=A9=20CD=20pipeline=20=EA=B5=AC?= =?UTF-8?q?=EC=B6=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/cd-be-dev-server.yml | 63 ++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 .github/workflows/cd-be-dev-server.yml diff --git a/.github/workflows/cd-be-dev-server.yml b/.github/workflows/cd-be-dev-server.yml new file mode 100644 index 000000000..138f239c0 --- /dev/null +++ b/.github/workflows/cd-be-dev-server.yml @@ -0,0 +1,63 @@ +name: Build and Deploy + +on: + 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: | + nohup java -jar build/libs/cruru-0.0.1-SNAPSHOT.jar & + echo "Lastest Backend API Server started."