This repository has been archived by the owner on Feb 6, 2025. It is now read-only.
Update README.md #36
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: Build | |
on: | |
push: | |
branches: [ main ] | |
pull_request: | |
branches: [ main ] | |
permissions: | |
contents: write # Garantisce i permessi di scrittura | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- name: Set up JDK 8 | |
uses: actions/setup-java@v3 | |
with: | |
java-version: '22' | |
distribution: 'temurin' | |
cache: maven | |
- name: Cache local Maven repository | |
uses: actions/cache@v3 | |
with: | |
path: ~/.m2/repository | |
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} | |
restore-keys: | | |
${{ runner.os }}-maven- | |
- name: Build with Maven | |
run: mvn -B package --file pom.xml | |
- name: Generate site | |
run: mvn jacoco:prepare-agent install jacoco:report | |
- name: Generate JaCoCo Badge | |
id: jacoco | |
uses: cicirello/[email protected] | |
with: | |
generate-branches-badge: true | |
jacoco-csv-file: target/site/jacoco/jacoco.csv | |
badges-directory: .github/badges | |
- name: Log coverage percentage | |
run: | | |
echo "coverage = ${{ steps.jacoco.outputs.coverage}}" | |
echo "branches = ${{ steps.jacoco.outputs.branches}}" | |
- name: Add badges | |
run: git add .github/badges | |
- name: Commit files | |
run: | | |
git config --global user.name 'github-actions' | |
git config --global user.email '41898282+github-actions[bot]@users.noreply.github.com' | |
git commit -m "Added coverage badges" -a || true | |
- name: Push changes | |
uses: ad-m/github-push-action@master | |
with: | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
branch: ${{ github.head_ref }} | |
- name: Upload coverage to Codecov | |
uses: codecov/codecov-action@v3 | |
with: | |
files: target/site/jacoco/jacoco.xml | |
token: ${{ secrets.CODECOV_TOKEN }} |