mirror of
https://github.com/valitydev/java-workflow.git
synced 2024-11-06 09:35:18 +00:00
62 lines
1.8 KiB
YAML
62 lines
1.8 KiB
YAML
name: Maven Build Artifact
|
|
|
|
on:
|
|
workflow_call:
|
|
inputs:
|
|
java-version:
|
|
description: 'Java version'
|
|
required: false
|
|
default: "17"
|
|
type: string
|
|
java-distribution:
|
|
description: 'Java distribution'
|
|
required: false
|
|
default: "temurin"
|
|
type: string
|
|
|
|
jobs:
|
|
build:
|
|
runs-on: ubuntu-22.04
|
|
steps:
|
|
- name: Install thrift
|
|
uses: valitydev/action-setup-thrift@v1.0.2
|
|
- name: Checkout Repo
|
|
uses: actions/checkout@v3
|
|
with:
|
|
fetch-depth: 0
|
|
- name: Set up Maven
|
|
uses: actions/setup-java@v3
|
|
with:
|
|
java-version: ${{ inputs.java-version }}
|
|
distribution: ${{ inputs.java-distribution }}
|
|
cache: 'maven'
|
|
- name: Retrieve commit info
|
|
run: |
|
|
echo "::set-output name=COMMIT_NUMBER::$(git rev-list HEAD --count)"
|
|
echo "::set-output name=SHA_7::${GITHUB_SHA::7}"
|
|
id: commit_info
|
|
- name: Build package
|
|
run: mvn --batch-mode -Dcommit.number=${{ steps.commit_info.outputs.COMMIT_NUMBER }} -Drevision="1.${{ steps.commit_info.outputs.COMMIT_NUMBER }}-${{ steps.commit_info.outputs.SHA_7 }}" clean compile site -f pom.xml
|
|
|
|
- name: Upload SBOM
|
|
uses: actions/upload-artifact@v3
|
|
with:
|
|
name: bom.json
|
|
path: 'target/bom.json'
|
|
|
|
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
|