Skip to content

Commit

Permalink
Added build on PRs to Git Workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
wakaleo committed Sep 8, 2024
1 parent 8368742 commit 795564e
Showing 1 changed file with 53 additions and 0 deletions.
53 changes: 53 additions & 0 deletions .github/workflows/pr-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: Pull Request Build - Java

# Trigger the workflow on pull requests to the main branch
on:
pull_request:
branches:
- main

jobs:
build:
runs-on: ubuntu-latest

steps:
# Step 1: Check out the repository code
- name: Checkout code
uses: actions/checkout@v3

# Step 2: Set up JDK 11
- name: Set up JDK 11
uses: actions/setup-java@v3
with:
java-version: '11'
distribution: 'adopt'

# Step 3: Cache Maven dependencies (optional but recommended)
- name: Cache Maven packages
uses: actions/cache@v3
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-
# Step 4: Run Maven Verify
- name: Run Maven Verify
run: mvn verify
continue-on-error: true # Allow the workflow to continue even if the build fails

# Step 5: Upload test results (JUnit XML reports) if tests fail
- name: Upload Test Results
if: failure() # Only upload if the build failed
uses: actions/upload-artifact@v3
with:
name: test-results
path: target/surefire-reports/*.xml # Path to the test results

# Step 6: Always upload the full logs to help debug failures
- name: Upload Build Logs
if: always() # Always upload logs, even if the build passes
uses: actions/upload-artifact@v3
with:
name: build-logs
path: target/*.log

0 comments on commit 795564e

Please sign in to comment.