Implemented Continuous Integration #1
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: Fleet Management CI/CD Pipeline | |
on: | |
push: | |
branches: [ main ] | |
pull_request: | |
branches: [ main ] | |
jobs: | |
build-and-test: | |
runs-on: ubuntu-latest | |
services: | |
postgres: | |
image: postgres:13 | |
env: | |
POSTGRES_USER: postgres | |
POSTGRES_PASSWORD: password | |
POSTGRES_DB: fleetmanagement | |
ports: | |
- 5432:5432 | |
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5 | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Set up JDK 17 | |
uses: actions/setup-java@v3 | |
with: | |
java-version: '17' | |
distribution: 'temurin' | |
cache: maven | |
- name: Cache Maven dependencies | |
uses: actions/cache@v3 | |
with: | |
path: ~/.m2/repository | |
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} | |
restore-keys: | | |
${{ runner.os }}-maven- | |
- name: Build and Run Tests with Maven | |
run: mvn -B clean verify | |
- name: Archive Test Reports | |
uses: actions/upload-artifact@v3 | |
with: | |
name: test-reports | |
path: target/surefire-reports | |
- name: Archive Production Artifact (If Tests Pass) | |
if: success() | |
uses: actions/upload-artifact@v3 | |
with: | |
name: package | |
path: target/*.jar |