Skip to content

Commit

Permalink
ci: add trivy image scanning (#1663)
Browse files Browse the repository at this point in the history
* add trivy image scanning

* implement as partial workflow

* support both the frontend and backend Dockerfiles for scanning

* fix docker build context location
  • Loading branch information
firefly2442 authored Dec 1, 2022
1 parent 82dc586 commit 0801f0a
Show file tree
Hide file tree
Showing 3 changed files with 70 additions and 0 deletions.
31 changes: 31 additions & 0 deletions .github/workflows/partial-trivy-backend-container-scanning.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Trivy Backend Container Scanning

on:
workflow_call:

jobs:
build:
name: Build and Scan Backend Container
runs-on: ubuntu-latest
strategy:
fail-fast: true
steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Build Dockerfile
run: |
docker build -t mealie .
- name: Run Trivy vulnerability scanner
uses: aquasecurity/trivy-action@master
with:
ignore-unfixed: true
image-ref: "mealie"
format: "sarif"
output: "trivy-results.sarif"

- name: Upload Trivy scan results to GitHub Security tab
uses: github/codeql-action/upload-sarif@v2
with:
sarif_file: "trivy-results.sarif"
31 changes: 31 additions & 0 deletions .github/workflows/partial-trivy-frontend-container-scanning.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Trivy Frontend Container Scanning

on:
workflow_call:

jobs:
build:
name: Build and Scan Frontend Container
runs-on: ubuntu-latest
strategy:
fail-fast: true
steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Build Dockerfile
run: |
docker build -t mealie ./frontend/
- name: Run Trivy vulnerability scanner
uses: aquasecurity/trivy-action@master
with:
ignore-unfixed: true
image-ref: "mealie"
format: "sarif"
output: "trivy-results.sarif"

- name: Upload Trivy scan results to GitHub Security tab
uses: github/codeql-action/upload-sarif@v2
with:
sarif_file: "trivy-results.sarif"
8 changes: 8 additions & 0 deletions .github/workflows/pull-requests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,11 @@ jobs:
frontend-tests:
name: "Frontend and End-to-End Tests"
uses: ./.github/workflows/partial-frontend.yml

backend-container-scanning:
name: "Trivy Backend Container Scanning"
uses: ./.github/workflows/partial-trivy-backend-container-scanning.yml

frontend-container-scanning:
name: "Trivy Frontend Container Scanning"
uses: ./.github/workflows/partial-trivy-frontend-container-scanning.yml

0 comments on commit 0801f0a

Please sign in to comment.