Skip to content

Commit

Permalink
scan images (#146)
Browse files Browse the repository at this point in the history
  • Loading branch information
keiranjprice101 authored Mar 15, 2024
1 parent 4e5d4c0 commit 55d2de0
Showing 1 changed file with 73 additions and 0 deletions.
73 changes: 73 additions & 0 deletions .github/workflows/trivy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
name: Image Scan
on:
schedule:
- cron: "49 8 * * *"

env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository_owner }}

jobs:
jobcontroller:
name: Trivy image scan
runs-on: ubuntu-20.04
steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Build Docker image
uses: docker/build-push-action@v5
with:
file: ./container/jobcontroller.D
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}/jobcontroller:${{ github.sha }}

- name: Run Trivy vulnerability scanner
uses: aquasecurity/trivy-action@master
with:
image-ref: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}/jobcontroller:${{ github.sha }}
format: sarif
output: trivy-results-jobcontroller.sarif
ignore-unfixed: true
exit-code: 1

- name: Print results
run: cat trivy-results-jobcontroller.sarif
if: failure()

- name: Upload Trivy scan results to GitHub Security tab
uses: github/codeql-action/upload-sarif@v2
if: failure()
with:
sarif_file: trivy-results-jobcontroller.sarif

runner:
name: Trivy runner image scan
runs-on: ubuntu-20.04
steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Build Docker image
uses: docker/build-push-action@v5
with:
file: ./container/runner.D
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}/runner:${{ github.sha }}

- name: Run Trivy vulnerability scanner
uses: aquasecurity/trivy-action@master
with:
image-ref: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}/runner:${{ github.sha }}
format: sarif
output: trivy-results-runner.sarif
ignore-unfixed: true
exit-code: 1

- name: Print results
run: cat trivy-results-runner.sarif
if: failure()

- name: Upload Trivy scan results to GitHub Security tab
uses: github/codeql-action/upload-sarif@v2
if: failure()
with:
sarif_file: trivy-results-runner.sarif

0 comments on commit 55d2de0

Please sign in to comment.