Skip to content

CI - Trivy Scan

CI - Trivy Scan #10

Workflow file for this run

name: CI - Trivy Scan
on:
schedule:
- cron: "0 0 * * *"
workflow_dispatch:
jobs:
trivy-scan:
runs-on: ubuntu-latest
permissions:
actions: read
contents: read
security-events: write
strategy:
fail-fast: false
matrix:
context: ["docker/web", "docker/api"]
include:
- context: docker/web
context_path: .
image_name: scv-web
sarif_file: trivy-web.sarif
docker_file: docker/web/Dockerfile.release
docker_build_args: |
WEB_BASE_HREF=/
NGINX_RUNTIME_SRC=../../docker/nginx-runtime
VUE_ON_NGINX_SRC=../../docker/vue-on-nginx
WEB_SRC=../../web
- context: docker/api
context_path: .
image_name: scv-api
sarif_file: trivy-api.sarif
docker_file: docker/api/Dockerfile.release
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup
uses: docker/setup-buildx-action@v3
with:
install: true
- name: Build
uses: docker/build-push-action@v6
with:
context: ${{matrix.context_path}}
file: ${{matrix.docker_file}}
push: false
load: true
tags: ${{matrix.image_name}}:latest
build-args: ${{matrix.docker_build_args}}
- name: Run Trivy vulnerability scanner- save to sarif file
uses: aquasecurity/trivy-action@cf990b19d84bbbe1eb8833659989a7c1029132e3
with:
scan-type: image
image-ref: ${{matrix.image_name}}:latest
format: "template"
ignore-unfixed: true
template: "@/contrib/sarif.tpl"
output: ${{matrix.sarif_file}}
severity: CRITICAL,HIGH,MEDIUM,LOW
- name: Upload Trivy scan results to GitHub Security tab
uses: github/codeql-action/upload-sarif@v3
with:
sarif_file: ${{matrix.sarif_file}}