Skip to content

Add JaCoCo plugin

Add JaCoCo plugin #285

Workflow file for this run

name: Build
on: [push, pull_request]
env:
MAVEN_OPTS: -Xms64m -Xmx512m
MAVEN_CLI_OPTS: -s .mvn/settings.xml -B -Dfrontend-build -Ddocker-build
MAVEN_GOALS: clean verify
DOCKER_REGISTRY: ghcr.io
DOCKER_REPO: ${{ github.repository_owner }}
DOCKER_IMAGE: karaplan
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: temurin
cache: maven
settings-path: ${{ github.workspace }}/.mvn
- name: Build webapp
run: ./mvnw ${MAVEN_CLI_OPTS} ${MAVEN_GOALS} -DskipTests
- name: Test webapp
run: ./mvnw ${MAVEN_CLI_OPTS} test
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: webapp
path: target/karaplan.war
- name: Publish artifacts
if: startsWith(github.ref, 'refs/tags')
run: ./mvnw ${MAVEN_CLI_OPTS} deploy -DskipTests
env:
GITHUB_TOKEN: ${{ github.token }}
- name: Login to Docker registry
if: startsWith(github.ref, 'refs/tags') || github.ref == 'refs/heads/master'
uses: docker/login-action@v3
with:
registry: ${{ env.DOCKER_REGISTRY }}
username: ${{ github.actor }}
password: ${{ github.token }}
- name: Build Docker image
if: startsWith(github.ref, 'refs/tags') || github.ref == 'refs/heads/master'
run: docker build -t "${DOCKER_REGISTRY}/${DOCKER_REPO}/${DOCKER_IMAGE}:${{ github.ref_name }}" target/docker-build
- name: Publish Docker image
if: startsWith(github.ref, 'refs/tags') || github.ref == 'refs/heads/master'
run: |
docker push "${DOCKER_REGISTRY}/${DOCKER_REPO}/${DOCKER_IMAGE}:${{ github.ref_name }}"
if [ "${{ github.ref_type }}" != "tag" ]; then
DOCKER_TAG="${{ github.ref_name }}-$(date +'%Y%m%d-%H%M')-$(echo ${{ github.sha }} | head -c 7)"
docker tag "${DOCKER_REGISTRY}/${DOCKER_REPO}/${DOCKER_IMAGE}:${{ github.ref_name }}" "${DOCKER_REGISTRY}/${DOCKER_REPO}/${DOCKER_IMAGE}:${DOCKER_TAG}"
docker push "${DOCKER_REGISTRY}/${DOCKER_REPO}/${DOCKER_IMAGE}:${DOCKER_TAG}"
fi