Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 50 additions & 13 deletions .github/workflows/github-actions-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,44 +2,81 @@ name: Java CI

# Trigger workflow on push or pull_request
# Note - the first pull_request from a forked repo will need to be given approval to run
on: [push, pull_request]
on:
push:
pull_request:
workflow_dispatch: # Adds a "Run workflow" button in GitHub Actions

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v7
with:
fetch-depth: 0 # Required by SonarCloud for accurate blame & new code detection

- name: Set up JDK 8
uses: actions/setup-java@v6
with:
java-version: '8'
distribution: 'temurin'
cache: 'maven'

- name: Cache Maven Repo
uses: actions/cache@v6
with:
path: ~/.m2
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
restore-keys: ${{ runner.os }}-m2

- name: Build Test and Verify
run: mvn -B -U clean install
- name: Build Test and Verify for JDK8
run: mvn -B -U clean verify

- name: Set up JDK 17
uses: actions/setup-java@v2
uses: actions/setup-java@v6
with:
java-version: '17'
distribution: 'adopt'
distribution: 'temurin'

- name: Build Test and Verify for JDK17
run: mvn -B -U clean verify

# Upload SBOMs
- name: Upload SBOMs as GitHub Artifact
uses: actions/upload-artifact@v7
with:
name: ${{ github.event.repository.name }}-sbom-${{ github.run_number }}
path: |
target/bom.json
target/bom.xml
overwrite: true
retention-days: 7

# Scan Project for vulnernabilities (Scanning the SBOM with trivy does not play nice with sonarcloud)
- name: Run Trivy vulnerability scanner
uses: aquasecurity/[email protected] # NOSONAR
with:
scan-type: 'fs'
scan-ref: '.'
scanners: 'vuln'
format: 'sarif'
output: 'target/trivy-results.sarif'
# Upload sarif
- name: Upload Trivy sarif
uses: actions/upload-artifact@v7
with:
name: ${{ github.event.repository.name }}-trivy-sarif-${{ github.run_number }}
path: target/trivy-results.sarif
overwrite: true
retention-days: 7

# Sonar Scan
- name: SonarCloud Scan
run: |
if ["$SONAR_TOKEN" == ""]; then
echo "Sonar secure variables NOT available"
else
echo "Sonar secure variables ARE available"
mvn -B org.sonarsource.scanner.maven:sonar-maven-plugin:sonar -Dsonar.projectKey="bordertech-java-common" -Dsonar.organization="bordertech-github" -Dsonar.host.url="https://sonarcloud.io" -Dsonar.qualitygate.wait=true
mvn -B org.sonarsource.scanner.maven:sonar-maven-plugin:sonar \
-Dsonar.projectKey="bordertech-java-common" \
-Dsonar.organization="bordertech-github" \
-Dsonar.host.url="https://sonarcloud.io" \
-Dsonar.qualitygate.wait=true \
-Dsonar.sarifReportPaths="target/trivy-results.sarif"
fi
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Expand Down
41 changes: 41 additions & 0 deletions .github/workflows/onrelease-sbom.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Generate Release SBOM

on:
release:
types: [published]

# Required permissions to attach the SBOM to the release
permissions:
contents: write

jobs:
sbom:
runs-on: ubuntu-latest

steps:

- name: Checkout release
uses: actions/checkout@v7

- name: Set up JDK 17
uses: actions/setup-java@v6
with:
java-version: '17'
distribution: 'temurin'
cache: 'maven'

- name: Build and Generate SBOM
env:
REPO_NAME: ${{ github.event.repository.name }}
TAG_NAME: ${{ github.event.release.tag_name }}
run: >
mvn -B -U package
-DskipTests=true
-DoutputFormat=json
-DoutputName="${REPO_NAME}-${TAG_NAME}.cdx"

- name: Upload SBOM to GitHub Release
uses: softprops/action-gh-release@v3 # NOSONAR
with:
files: target/*.cdx.json
fail_on_unmatched_files: true
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

## Release in-progress

* Update release tag format to vX.X.X.
* Added cyclonedx-maven-plugin to bordertech-parent to generate SBOMs.

## 1.0.24
* Configure OWASP dependency-check-maven plugin to use the NVD JSON 2.0 Data Feed to avoid the null API key bug introduced in version 13.0.0.
* Add new profile `check-convergence` as a convenient profile to check dependency convergence without doing a full build.
Expand Down
18 changes: 18 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<!-- Default release profile -->
<releaseProfiles>central-release</releaseProfiles>
<!-- Override default release tag format -->
<tagNameFormat>v@{project.version}</tagNameFormat>
</properties>

<!--
Expand Down Expand Up @@ -177,6 +179,22 @@

<plugins>

<!-- Generate aggregated SBOMs (ie target/bom.json and target/bom.xml) -->
<plugin>
<groupId>org.cyclonedx</groupId>
<artifactId>cyclonedx-maven-plugin</artifactId>
<version>2.9.3</version>
<executions>
<execution>
<id>generate-sbom</id>
<phase>package</phase>
<goals>
<goal>makeAggregateBom</goal>
</goals>
</execution>
</executions>
</plugin>

<!-- Compile the java source. -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
Expand Down