java-workflow/.github/workflows/maven-library-build.yml

92 lines
2.3 KiB
YAML
Raw Normal View History

2022-01-20 13:05:17 +00:00
name: Maven Build Artifact
on:
workflow_call:
2022-01-27 13:58:42 +00:00
inputs:
java-version:
description: 'Java version'
required: false
2023-01-19 13:27:59 +00:00
default: "17"
2022-01-27 13:58:42 +00:00
type: string
java-distribution:
description: 'Java distribution'
required: false
2023-01-19 13:27:59 +00:00
default: "temurin"
2022-01-27 13:58:42 +00:00
type: string
2022-11-15 16:04:54 +00:00
mvn-options:
description: 'Additional maven options'
required: false
default: ""
type: string
mvn-args:
description: 'Additional maven args'
required: false
default: ""
type: string
2022-01-20 13:05:17 +00:00
jobs:
build:
runs-on: ubuntu-20.04
steps:
2022-01-24 10:01:12 +00:00
- name: Checkout Repo
uses: actions/checkout@v3
2022-01-24 10:01:12 +00:00
2022-01-27 13:58:42 +00:00
- name: Set up JDK
uses: actions/setup-java@v3
2022-01-20 13:05:17 +00:00
with:
2022-01-27 13:58:42 +00:00
java-version: ${{ inputs.java-version }}
distribution: ${{ inputs.java-distribution }}
cache: 'maven'
2022-01-24 10:01:12 +00:00
2022-01-27 13:58:42 +00:00
- name: Maven Compile
2022-11-15 16:04:54 +00:00
run: |
mvn \
--no-transfer-progress \
--batch-mode ${{ inputs.mvn-options }} \
2023-06-30 03:05:33 +00:00
clean compile site
2023-06-28 21:55:49 +00:00
- name: Upload SBOM
uses: actions/upload-artifact@v3
with:
name: bom.json
path: 'target/bom.json'
2022-01-24 10:01:12 +00:00
2022-01-27 13:58:42 +00:00
test-coverage:
runs-on: ubuntu-20.04
steps:
- name: Checkout Repo
uses: actions/checkout@v3
2022-01-27 13:58:42 +00:00
- name: Set up JDK
uses: actions/setup-java@v3
2022-01-27 13:58:42 +00:00
with:
java-version: ${{ inputs.java-version }}
distribution: ${{ inputs.java-distribution }}
cache: 'maven'
- name: Maven Verify
2022-11-15 16:04:54 +00:00
run: |
mvn \
--no-transfer-progress \
--batch-mode ${{ inputs.mvn-options }} \
clean verify ${{ inputs.mvn-args }}
2022-01-27 13:58:42 +00:00
2022-01-24 09:16:48 +00:00
- name: Upload code coverage
uses: codecov/codecov-action@v3
2023-06-28 21:55:49 +00:00
scan:
name: Scan with Trivy
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Install Trivy CLI
run: |
wget https://github.com/aquasecurity/trivy/releases/download/v0.39.1/trivy_0.39.1_Linux-64bit.deb
sudo dpkg -i trivy_0.39.1_Linux-64bit.deb
- uses: actions/download-artifact@v3
with:
name: bom.json
- name: Run Trivy with SBOM
run: trivy sbom --exit-code 1 --severity CRITICAL,HIGH ./bom.json