-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
vsc1cob
committed
Jan 20, 2025
1 parent
b3e0309
commit e2ed1a3
Showing
6 changed files
with
155 additions
and
120 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
name: Build and Artifact | ||
|
||
runs-on: self-hosted | ||
|
||
steps: | ||
# Checkout the repository | ||
- name: Checkout Code | ||
uses: actions/checkout@v3 | ||
|
||
# Build the project with Maven | ||
- name: Build with Maven | ||
run: mvn clean install | ||
|
||
# Store artifacts with versioning | ||
- name: Upload Artifacts with Versioning | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: my-app-artifact-${{ github.sha }} | ||
path: target/*.jar |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
name: Build, Deploy, and Analyze | ||
|
||
on: | ||
push: | ||
branches: | ||
- '**' | ||
pull_request: | ||
branches: | ||
- master | ||
workflow_dispatch: | ||
|
||
jobs: | ||
setup-java-maven: | ||
uses: ./.github/workflows/setup-java-maven.yml | ||
|
||
build-and-artifact: | ||
uses: ./.github/workflows/build-and-artifact.yml | ||
needs: setup-java-maven | ||
|
||
springboot-run-stop: | ||
uses: ./.github/workflows/springboot-run-stop.yml | ||
needs: build-and-artifact | ||
|
||
sonarcloud-analysis: | ||
uses: ./.github/workflows/sonarcloud-analysis.yml | ||
needs: build-and-artifact |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
name: Setup Java and Maven | ||
|
||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
# Checkout the repository | ||
- name: Checkout Code | ||
uses: actions/checkout@v3 | ||
|
||
# Install Maven | ||
- name: Install Maven | ||
run: | | ||
sudo apt update | ||
sudo apt install maven -y | ||
mvn -v | ||
# Set up Java | ||
- name: Set up Java | ||
uses: actions/setup-java@v3 | ||
with: | ||
java-version: '17' | ||
distribution: 'temurin' | ||
cache: maven | ||
|
||
# Cache Maven dependencies | ||
- name: Cache Maven dependencies | ||
uses: actions/cache@v3 | ||
with: | ||
path: ~/.m2 | ||
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} | ||
restore-keys: | | ||
${{ runner.os }}-maven- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
name: SonarCloud Analysis | ||
|
||
runs-on: self-hosted | ||
needs: build-and-artifact # Ensure the build and artifact job runs before the SonarCloud analysis job | ||
|
||
steps: | ||
# Checkout the repository | ||
- name: Checkout Code | ||
uses: actions/checkout@v3 | ||
|
||
# Set up Java | ||
- name: Set up Java | ||
uses: actions/setup-java@v3 | ||
with: | ||
java-version: '17' | ||
distribution: 'temurin' | ||
|
||
# SonarCloud Analysis | ||
- name: SonarCloud Analysis | ||
env: | ||
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} | ||
SONAR_ORG: your-organization # Replace with your actual SonarCloud organization | ||
SONAR_HOST_URL: https://sonarcloud.io | ||
run: | | ||
mvn clean verify sonar:sonar \ | ||
-Dsonar.organization=${{ secrets.SONAR_ORG }} \ | ||
-Dsonar.host.url=${{ secrets.SONAR_HOST_URL }} \ | ||
-Dsonar.login=${{ secrets.SONAR_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
name: Spring Boot Run and Stop | ||
|
||
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 |