Coverage badge GitAction setup #34
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: test and docker | |
on: | |
push: | |
branches: | |
- master | |
jobs: | |
# Build and test the applications with multiple Java versions | |
build-and-test: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
java-version: [ | |
'11.0.x', | |
'16.0.x', | |
'17.0.x', | |
'18.0.x', | |
] | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: JDK Set up | |
uses: actions/setup-java@v3 | |
with: | |
java-version: ${{ matrix.java-version }} | |
architecture: x64 | |
distribution: 'temurin' | |
cache: 'maven' | |
- name: Package privacydashboard | |
run: mvn clean package -Pproduction | |
- name: Coverage Report | |
run: mvn jacoco:report | |
- name: Deploy Jacoco code coverage reports to gh-pages | |
uses: JamesIves/github-pages-deploy-action@v4 | |
if: ${{ matrix.java-version == '18.0.x' }} | |
with: | |
clean: true | |
folder: target/site/jacoco | |
target-folder: reports | |
branch: gh-pages | |
# Build files necessary for building Docker Images (Dockerfiles and Contexts) | |
build-for-docker: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: actions/setup-java@v3 | |
with: | |
java-version: "18.0.x" | |
architecture: x64 | |
distribution: 'temurin' | |
cache: 'maven' | |
- name: Prepare Dockerfiles and files for Contexts | |
run: docker build . --file Dockerfile --tag privacydashboard:latest | |
- name: Upload artifacts for Docker Image building | |
uses: actions/upload-artifact@v3 | |
with: | |
name: files-for-docker | |
retention-days: 5 | |
if-no-files-found: error | |
path: | | |
./* | |
# Build multiarch Docker Images and push as GitHub Packages | |
docker-image-push: | |
if: ${{ github.repository == 'sifis-home/privacydashboard' }} | |
needs: [build-and-test, build-for-docker] | |
runs-on: ubuntu-latest | |
steps: | |
- name: Download artifacts for Docker Image building | |
uses: actions/download-artifact@v3 | |
with: | |
name: files-for-docker | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v2 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v2 | |
- name: Login to GitHub container registry (ghcr.io) | |
uses: docker/login-action@v2 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Build and push image | |
uses: docker/build-push-action@v4 | |
with: | |
context: ./ | |
file: ./Dockerfile | |
push: true | |
tags: ghcr.io/sifis-home/privacydashboard:latest | |
outputs: type=registry, annotation-index.org.opencontainers.image.description=privacydashboard - Privacydashboard Image | |