Added artifacts

This commit is contained in:
YouWenKee 2024-08-14 10:44:55 +08:00
parent 291086370b
commit 3f9db9d81e

View file

@ -2,11 +2,9 @@ name: CI Pipeline
on:
push:
branches:
- main
branches: [ main ]
pull_request:
branches:
- main
branches: [ main ]
jobs:
build:
@ -14,37 +12,40 @@ jobs:
steps:
- name: Checkout code
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
distribution: 'adopt'
java-version: '17'
- 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: Set up PostgreSQL
uses: harmon758/postgresql-action@v1.0.0
with:
postgresql version: '13'
postgresql db: 'petclinic'
postgresql user: 'postgres'
postgresql password: 'password'
- name: Build with Maven
run: mvn clean install
- name: Run tests
- name: Upload Build Artifacts
uses: actions/upload-artifact@v3
with:
name: build-artifacts
path: target/**
- name: Run Unit Tests
run: mvn test
- name: Build Docker image
run: docker build -t petclinic-app .
- name: Upload Test Reports
uses: actions/upload-artifact@v3
with:
name: test-reports
path: target/surefire-reports/**
- name: Push Docker image
run: docker push your-dockerhub-username/petclinic-app
- name: Generate Code Coverage Report
run: mvn jacoco:report
- name: Upload Code Coverage Report
uses: actions/upload-artifact@v3
with:
name: code-coverage-report
path: target/site/jacoco/**
- name: Run Deployment
run: java -jar target/your-app.jar