Skip to content

Feature

Feature #31

name: Development CI-CD
on:
push:
branches: [ "develop" ]
pull_request:
branches: [ "develop" ]
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
permissions:
statuses: write
checks: write
contents: write
pull-requests: write
steps:
- uses: actions/checkout@v4
- name: Set up JDK 21
uses: actions/setup-java@v4
with:
java-version: '21'
distribution: 'temurin'
cache: maven
- name: Cache Maven packages
uses: actions/cache@v3
with:
path: ~/.m2
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
restore-keys: ${{ runner.os }}-m2
- name: Run Maven Build Command
run: mvn clean install -DskipTests -Pdevelopment
- name: Run Maven Test
run: mvn test -Pdevelopment
- name: Unit Test Results
uses: dorny/test-reporter@v1
if: success() || failure()
with:
name: Development-Unit-Test-Results
path: target/surefire-reports/*.xml
reporter: java-junit
- name: Run Maven Jacoco
run: mvn jacoco:report
- name: JaCoCo Code Coverage Report
id: jacoco_reporter
uses: PavanMudigonda/[email protected]
with:
coverage_results_path: 'target/site/jacoco/jacoco.xml'
coverage_report_name: Coverage
coverage_report_title: JaCoCo
github_token: ${{ secrets.GITHUB_TOKEN }}
# Publish Coverage Job Summary
- name: Add Coverage Job Summary
run: echo "${{ steps.jacoco_reporter.outputs.coverageSummary }}" >> $GITHUB_STEP_SUMMARY
- name: Log in to the Container registry
uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7
with:
images: duongminhhieu008/rookie-phase1-development
- name: Build and push Docker images
uses: docker/build-push-action@3b5e8027fcad23fda98b2e3ac259d8d67585f671
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}