From 3f9db9d81ed6327cc812c2872a09a1f9c99c1ed4 Mon Sep 17 00:00:00 2001 From: YouWenKee Date: Wed, 14 Aug 2024 10:44:55 +0800 Subject: [PATCH] Added artifacts --- .github/workflows/ci.yml | 53 ++++++++++++++++++++-------------------- 1 file changed, 27 insertions(+), 26 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3290e6588..5541bc250 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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