🔧 jacoco v2 #30
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: Java CI with Maven | |
on: | |
push: | |
branches: | |
- main | |
pull_request: | |
branches: | |
- main | |
jobs: | |
unit-test: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v2 | |
with: | |
fetch-depth: 0 | |
- name: Set up JDK 17 | |
uses: actions/setup-java@v2 | |
with: | |
java-version: '17' | |
distribution: 'adopt' | |
- name: Build with Maven | |
run: mvn clean install | |
- name: Run tests | |
run: mvn test | |
- name: Publish JaCoCo Report | |
if: success() # Only run if previous steps succeeded | |
run: | | |
mkdir -p coverage | |
cp -r target/site/jacoco/* coverage/ | |
echo "JaCoCo report generated at: coverage/index.html" | |
- name: Upload JaCoCo report | |
uses: actions/upload-artifact@v3 | |
with: | |
name: jacoco-report | |
path: coverage | |
build: | |
runs-on: ubuntu-latest | |
needs: unit-test | |
steps: | |
- name: Check out code | |
uses: actions/checkout@v2 | |
- name: Set up JDK 17 | |
uses: actions/setup-java@v2 | |
with: | |
java-version: '17' | |
distribution: 'adopt' | |
- name: Build with Maven | |
run: mvn clean install | |
- name: Run tests | |
run: mvn test | |
publish: | |
runs-on: ubuntu-latest | |
needs: build | |
if: github.ref == 'refs/heads/main' | |
steps: | |
- name: Check out code | |
uses: actions/checkout@v2 | |
- name: Set up JDK 17 | |
uses: actions/setup-java@v2 | |
with: | |
java-version: '17' | |
distribution: 'adopt' | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v1 | |
with: | |
version: v0.7.0 | |
- name: Build the Docker image | |
run: docker build -t migprogrammer/neighborfood-clean:latest . | |
- name: Log into Docker Hub | |
run: docker login -u migprogrammer -p ${{secrets.DOCKERHUB_TOKEN}} | |
- name: Push image to Docker Hub | |
run: docker push migprogrammer/neighborfood-clean:latest |