From d4a69413788b9b6908ccd7e5ce8169aa293d53fb Mon Sep 17 00:00:00 2001 From: Sachin Date: Sat, 30 Nov 2024 17:10:36 +0530 Subject: [PATCH] Create maven.yml --- maven.yml | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 maven.yml diff --git a/maven.yml b/maven.yml new file mode 100644 index 0000000..eee958d --- /dev/null +++ b/maven.yml @@ -0,0 +1,38 @@ +name: Maven Build Pipeline + +on: + push: + branches: + - main # Triggers the workflow on push to the 'main' branch + pull_request: + branches: + - main # Triggers on pull requests to the 'main' branch + +jobs: + build: + runs-on: ubuntu-latest # Use the latest Ubuntu runner + + steps: + # Step 1: Check out the repository + - name: Checkout Code + uses: actions/checkout@v3 + + # Step 2: Set up JDK (Java 17 as an example) + - name: Set up JDK 17 + uses: actions/setup-java@v3 + with: + java-version: 17 + distribution: 'temurin' + + # Step 3: Cache Maven dependencies to speed up builds + - name: Cache Maven Dependencies + uses: actions/cache@v3 + with: + path: ~/.m2/repository + key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} + restore-keys: | + ${{ runner.os }}-maven- + + # Step 4: Build the project using Maven + - name: Build with Maven + run: mvn clean install