Skip to content

Commit

Permalink
adding templates
Browse files Browse the repository at this point in the history
  • Loading branch information
vsc1cob committed Jan 20, 2025
1 parent 5feed07 commit 071951b
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 62 deletions.
3 changes: 0 additions & 3 deletions .github/workflows/build-and-artifact.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@ jobs:
runs-on: self-hosted

steps:
- name: Checkout Code
uses: actions/checkout@v3

# Build the project with Maven
- name: Build with Maven
run: mvn clean install
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ jobs:
build-and-artifact:
uses: ./.github/workflows/build-and-artifact.yml # Reference to the build workflow

# # Call the Spring Boot run and stop workflow
# springboot-run-stop:
# uses: ./.github/workflows/springboot-run-stop.yml # Reference to the Spring Boot workflow
# Call the Spring Boot run and stop workflow
springboot-run-stop:
uses: ./.github/workflows/springboot-run-stop.yml # Reference to the Spring Boot workflow

# # Call the SonarCloud analysis workflow
# sonarcloud-analysis:
Expand Down
104 changes: 48 additions & 56 deletions .github/workflows/springboot-run-stop.yml
Original file line number Diff line number Diff line change
@@ -1,59 +1,51 @@
name: Spring Boot Run and Stop

on:
push:
branches:
- '**' # Trigger for all branches
pull_request:
branches:
- master # Trigger for pull requests targeting the master branch
workflow_dispatch: # Manual trigger via GitHub UI

runs-on: self-hosted

steps:
# Checkout the repository
- name: Checkout Code
uses: actions/checkout@v3

# Run Spring Boot App
- name: Run Spring Boot App
run: mvn spring-boot:run &

# Wait for the Spring Boot app to fully start
- name: Wait for Spring Boot App to Start
run: |
echo "Waiting for the app to start..."
sleep 15
echo "App should now be running."
# Validate that the application is running
- name: Validate App is Running
run: |
echo "Checking if the app is running..."
IP_ADDRESS=$(curl -s ifconfig.me)
PORT=8080
RESPONSE=$(curl --write-out "%{http_code}" --silent --output /dev/null http://$IP_ADDRESS:$PORT)
if [ "$RESPONSE" -eq 200 ]; then
echo "The app is running successfully at http://$IP_ADDRESS:$PORT!"
else
echo "The app failed to start. HTTP response code: $RESPONSE"
exit 1
fi
# Display the IP address and port number
- name: Display IP Address and Port
run: |
echo "The app is accessible at: http://$IP_ADDRESS:$PORT"
# Wait for 3 minutes
- name: Wait for 3 minutes
run: |
echo "App has been running for 3 minutes. Waiting..."
sleep 180
# Gracefully Stop Spring Boot App
- name: Gracefully Stop Spring Boot App
run: |
echo "Stopping the app gracefully..."
mvn spring-boot:stop
workflow_call: # This workflow can be called from other workflows

jobs:
springboot-run-stop:
runs-on: self-hosted

steps:
# Run Spring Boot App
- name: Run Spring Boot App
run: mvn spring-boot:run &

# Wait for the Spring Boot app to fully start
- name: Wait for Spring Boot App to Start
run: |
echo "Waiting for the app to start..."
sleep 15
echo "App should now be running."
# Validate that the application is running
- name: Validate App is Running
run: |
echo "Checking if the app is running..."
IP_ADDRESS=$(curl -s ifconfig.me) # Fetch public IP address
PORT=8080
RESPONSE=$(curl --write-out "%{http_code}" --silent --output /dev/null http://$IP_ADDRESS:$PORT)
if [ "$RESPONSE" -eq 200 ]; then
echo "The app is running successfully at http://$IP_ADDRESS:$PORT!"
else
echo "The app failed to start. HTTP response code: $RESPONSE"
exit 1
fi
# Display the IP address and port number
- name: Display IP Address and Port
run: |
echo "The app is accessible at: http://$IP_ADDRESS:$PORT"
# Wait for 3 minutes (180 seconds)
- name: Wait for 3 minutes
run: |
echo "App has been running for 3 minutes. Waiting..."
sleep 180
# Gracefully Stop Spring Boot App
- name: Gracefully Stop Spring Boot App
run: |
echo "Stopping the app gracefully..."
mvn spring-boot:stop

0 comments on commit 071951b

Please sign in to comment.