Image Scan #236
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: Image Scan | |
on: | |
schedule: | |
- cron: "49 8 * * *" | |
env: | |
REGISTRY: ghcr.io | |
IMAGE_NAME: ${{ github.repository_owner }} | |
jobs: | |
dockerfile_matrix: | |
strategy: | |
matrix: | |
image_name: ["jobcreator", "jobwatcher", "runner"] | |
dockerfile: ["job_creator.Dockerfile", "job_watcher.Dockerfile", "runner.Dockerfile"] | |
exclude: | |
- image_name: jobcreator | |
dockerfile: job_watcher.Dockerfile | |
- image_name: jobcreator | |
dockerfile: runner.Dockerfile | |
- image_name: jobwatcher | |
dockerfile: job_creator.Dockerfile | |
- image_name: jobwatcher | |
dockerfile: runner.Dockerfile | |
- image_name: runner | |
dockerfile: job_creator.Dockerfile | |
- image_name: runner | |
dockerfile: job_watcher.Dockerfile | |
fail-fast: false | |
runs-on: ubuntu-20.04 | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Build Docker image | |
uses: docker/build-push-action@v5 | |
with: | |
file: ./container/${{ matrix.dockerfile }} | |
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}/${{ matrix.image_name }}:${{ github.sha }} | |
- name: Run Trivy vulnerability scanner | |
uses: aquasecurity/trivy-action@master | |
with: | |
image-ref: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}/${{ matrix.image_name}}:${{ github.sha }} | |
format: sarif | |
output: trivy-results-${{ matrix.image_name }}.sarif | |
ignore-unfixed: true | |
exit-code: 1 | |
severity: "CRITICAL,HIGH" | |
- name: Print results | |
run: cat trivy-results-${{ matrix.image_name }}.sarif | |
if: failure() | |
- name: Upload Trivy scan results to GitHub Security tab | |
uses: github/codeql-action/upload-sarif@v3 | |
if: failure() | |
with: | |
sarif_file: trivy-results-${{ matrix.image_name }}.sarif |