Java CI with Maven #422
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
# This workflow will build a Java project with Maven, and cache/restore any dependencies to improve the workflow execution time | |
# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-maven | |
name: Java CI with Maven | |
on: | |
push: | |
branches: [ "master", "develop" ] | |
pull_request: | |
branches: [ "master", "develop" ] | |
workflow_dispatch: # Allows you to run this workflow manually from the Actions tab | |
schedule: | |
- cron: "0 8 * * 1" #Runs pipeline once a week https://jasonet.co/posts/scheduled-actions/ | |
jobs: | |
build-analyze: | |
runs-on: ubuntu-latest | |
env: | |
version: 1.3.${{ github.run_number }} | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Set up JDK 11 | |
uses: actions/setup-java@v3 | |
with: | |
java-version: '11' | |
distribution: 'corretto' | |
cache: maven | |
- name: Initialize CodeQL | |
uses: github/codeql-action/init@v2 | |
with: | |
languages: 'java' | |
- name: Build | |
run: mvn -V -B clean package org.jacoco:jacoco-maven-plugin:0.8.7:prepare-agent org.jacoco:jacoco-maven-plugin:0.8.7:report -Pcoverage -Dproject.version=${{ env.version }}-SNAPSHOT | |
- name: Upload Build Artifact | |
uses: actions/upload-artifact@v3 | |
with: | |
name: KeepTime-${{ env.version }} | |
path: /home/runner/work/KeepTime/KeepTime/target/*-bin.zip | |
- name: Analyze | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} | |
run: mvn -V -B sonar:sonar | |
-Dsonar.host.url=${{ secrets.HOST_URL }} | |
-Dsonar.organization=${{ secrets.ORGANIZATION_NAME }} | |
-Dsonar.projectKey=${{ secrets.PROJECT_KEY }} | |
-Dsonar.java.binaries=. | |
-Dsonar.qualitygate.wait=false | |
- name: Perform CodeQL Analysis | |
uses: github/codeql-action/analyze@v2 | |
dependency-check: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Set up JDK 11 | |
uses: actions/setup-java@v3 | |
with: | |
java-version: '11' | |
distribution: 'corretto' | |
cache: maven | |
- name: dependencyCheck | |
run: mvn dependency-check:check |