Skip to content

NIGHTLY-SCAN

NIGHTLY-SCAN #1466

Workflow file for this run

name: NIGHTLY-SCAN
on:
schedule:
- cron: '0 1 * * *'
workflow_dispatch:
jobs:
get-matrix-values:
runs-on: ubuntu-latest
outputs:
image: ${{ steps.set-var.outputs.image }}
steps:
- uses: actions/checkout@v4
- id: set-var
run: |
echo 'image<<EOF' >> $GITHUB_OUTPUT
cat ./image-matrix.json >> $GITHUB_OUTPUT
echo 'EOF' >> $GITHUB_OUTPUT
nightly-scan:
runs-on: ubuntu-latest
needs: get-matrix-values
strategy:
fail-fast: false
matrix:
image: ${{fromJSON(needs.get-matrix-values.outputs.image)}}
steps:
- uses: actions/checkout@v4
- name: Set job environment variables
run: cat JOB.env >> $GITHUB_ENV
- name: Run Anchore Grype scan
id: grype-scan
uses: anchore/scan-action@v6
with:
image: defradigital/${{env.IMAGE_NAME}}:${{env.DEFRA_VERSION}}-dotnet${{matrix.image.netVersion}}
fail-build: true
severity-cutoff: "medium"
continue-on-error: true
- name: Run Aqua Trivy scan
id: trivy-scan
uses: aquasecurity/trivy-action@57a97c7e7821a5776cebc9bb87c984fa69cba8f1
with:
image-ref: defradigital/${{env.IMAGE_NAME}}:${{env.DEFRA_VERSION}}-dotnet${{matrix.image.netVersion}}
format: sarif
output: trivy-reports-dotnet-${{ matrix.image.netVersion }}
exit-code: 1
vuln-type: os,library
severity: CRITICAL,HIGH,MEDIUM
continue-on-error: true
- name: Upload Grype SARIF report
if: ${{ steps.grype-scan.outcome == 'failure' }}
uses: actions/upload-artifact@v4
with:
name: grype-reports-dotnet-${{ matrix.image.netVersion }}
path: ${{ steps.grype-scan.outputs.sarif }}
- name: Upload Trivy SARIF report
if: ${{ steps.trivy-scan.outcome == 'failure' }}
uses: actions/upload-artifact@v4
with:
name: trivy-reports-dotnet-${{ matrix.image.netVersion }}
path: trivy-reports-dotnet-${{ matrix.image.netVersion }}
- name: Fail build if scans failed
if: ${{ (steps.grype-scan.outcome == 'failure' || steps.trivy-scan.outcome == 'failure') }}
run: |
echo "One or more scans failed. Failing the build."
exit 1