fix: Update repo to work with cstar cluster #137
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
name: Pull request validation | |
on: | |
pull_request: | |
branches: | |
- main | |
types: | |
- opened | |
- edited | |
- synchronize | |
jobs: | |
pr-validation: | |
runs-on: ubuntu-latest | |
outputs: | |
CVE_CRITICAL: ${{env.CVE_CRITICAL}} | |
CVE_HIGH: ${{env.CVE_HIGH}} | |
CVE_MEDIUM: ${{env.CVE_MEDIUM}} | |
steps: | |
- name: PR title validation | |
uses: amannn/action-semantic-pull-request@c3cd5d1ea3580753008872425915e343e351ab54 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
types: | | |
docs | |
refactor | |
chore | |
fix | |
feat | |
breaking | |
requireScope: false | |
subjectPattern: ^[A-Z].+$ | |
subjectPatternError: | | |
The subject "{subject}" found in the pull request title "{title}" | |
doesn't match the configured pattern. Please ensure that the subject | |
starts with an uppercase character. | |
wip: false | |
- name: Checkout the source code | |
uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab | |
with: | |
token: ${{ secrets.GIT_PAT }} | |
fetch-depth: 0 | |
- name: Cache JDK | |
uses: actions/cache@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8 | |
id: cache-jdk | |
with: | |
key: OpenJDK21U-jdk_x64_linux_hotspot_21.0.2_13.tar.gz | |
path: | | |
${{ runner.temp }}/jdk_setup.tar.gz | |
${{ runner.temp }}/jdk_setup.sha256 | |
- name: Download JDK and verify its hash | |
if: steps.cache-jdk.outputs.cache-hit != 'true' | |
run: | | |
echo "454bebb2c9fe48d981341461ffb6bf1017c7b7c6e15c6b0c29b959194ba3aaa5 ${{ runner.temp }}/jdk_setup.tar.gz" >> ${{ runner.temp }}/jdk_setup.sha256 | |
curl -L "https://github.com/adoptium/temurin21-binaries/releases/download/jdk-21.0.2%2B13/OpenJDK21U-jdk_x64_linux_hotspot_21.0.2_13.tar.gz" -o "${{ runner.temp }}/jdk_setup.tar.gz" | |
sha256sum --check --status "${{ runner.temp }}/jdk_setup.sha256" | |
- name: Setup JDK | |
uses: actions/setup-java@5ffc13f4174014e2d4d4572b3d74c3fa61aeb2c2 | |
with: | |
distribution: "jdkfile" | |
jdkFile: "${{ runner.temp }}/jdk_setup.tar.gz" | |
java-version: "21" | |
cache: maven | |
- name: Cache Maven | |
uses: actions/cache@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8 | |
id: cache-maven | |
with: | |
key: apache-maven-3.9.6-bin.tar.gz | |
path: | | |
${{ runner.temp }}/maven_setup.tar.gz | |
${{ runner.temp }}/maven_setup.sha256 | |
- name: Download Maven and verify its hash | |
if: steps.cache-maven.outputs.cache-hit != 'true' | |
run: | | |
echo "6eedd2cae3626d6ad3a5c9ee324bd265853d64297f07f033430755bd0e0c3a4b ${{ runner.temp }}/maven_setup.tar.gz" >> ${{ runner.temp }}/maven_setup.sha256 | |
curl -L "https://archive.apache.org/dist/maven/maven-3/3.9.6/binaries/apache-maven-3.9.6-bin.tar.gz" -o "${{ runner.temp }}/maven_setup.tar.gz" | |
sha256sum --check --status "${{ runner.temp }}/maven_setup.sha256" | |
- name: Setup Maven | |
run: | | |
mkdir ${{ runner.temp }}/maven | |
tar -xvf ${{ runner.temp }}/maven_setup.tar.gz -C ${{ runner.temp }}/maven --strip-components=1 | |
echo "<settings><servers><server><id>github</id><username>${{ secrets.GIT_USER }}</username><password>${{ secrets.GIT_PAT }}</password></server></servers></settings>" >> ${{ runner.temp }}/settings.xml | |
- name: Execute unit-test + Calculate test coverage + SCA with Sonar | |
env: | |
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} | |
run: ${{ runner.temp }}/maven/bin/mvn verify -Pvalidate -s ${{ runner.temp }}/settings.xml --no-transfer-progress | |
- name: Run the Trivy scan action itself with GitHub Advanced Security code scanning integration enabled | |
id: scan | |
uses: aquasecurity/trivy-action@595be6a0f6560a0a8fc419ddf630567fc623531d # v0.22.0 | |
with: | |
scan-type: 'fs' | |
ignore-unfixed: true | |
format: 'sarif' | |
output: 'results.sarif' | |
- name: Upload Anchore Scan Report | |
uses: github/codeql-action/upload-sarif@9550da953dd3b29aedf76cd635101e48eae5eebd # CodeQL Bundle v2.17.4 | |
with: | |
sarif_file: 'results.sarif' | |
- name: CVE Description escaped extraction and print | |
run: | | |
SCAN_RESULTS=$(jq -r 'try .runs[0].tool.driver.rules | map(.help.text) | join("\\n")' results.sarif) | |
echo "CVE_CRITICAL=$(echo $SCAN_RESULTS | grep -o CRITICAL | wc -l)" >> $GITHUB_ENV | |
echo "CVE_HIGH=$(echo $SCAN_RESULTS | grep -o HIGH | wc -l)" >> $GITHUB_ENV | |
echo "CVE_MEDIUM=$(echo $SCAN_RESULTS | grep -o MEDIUM | wc -l)" >> $GITHUB_ENV | |
echo $SCAN_RESULTS | |
- name: Fails if CVE HIGH or CRITICAL are detected | |
id: cve-threshold | |
if: env.CVE_HIGH > 0 || env.CVE_CRITICAL > 0 | |
run: exit 1 |