Merge pull request #54 from Hoxtygen/fix-automerge-github-action-job-… #10
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
name: CI Pipeline | |
on: | |
push: | |
branches: | |
- main | |
- develop | |
- staging | |
pull_request: | |
branches: | |
- main | |
- develop | |
- staging | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
services: | |
redis: | |
image: redis:latest | |
ports: | |
- 6379:6379 | |
steps: | |
# Step 1: Checkout the repository | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
# Step 2: Set up JDK 17 | |
- name: Set up JDK 17 | |
uses: actions/setup-java@v3 | |
with: | |
distribution: "adopt" | |
java-version: "17" | |
# Step 3: Grant execute permission to Maven wrapper | |
- name: Grant execute permission to Maven wrapper | |
run: chmod +x ./mvnw | |
# Step 4: 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 5: Build and run tests with Maven | |
- name: Build and Test with Maven | |
run: | | |
./mvnw clean test -Dspring.profiles.active=test | |
# Step 6: Upload test results (optional but recommended for reporting) | |
- name: Upload test results | |
if: always() | |
uses: actions/upload-artifact@v3 | |
with: | |
name: test-results | |
path: target/surefire-reports/ |