summaryrefslogtreecommitdiff
path: root/.github/workflows/image-scan.yml
blob: 78a4f2a38e7a75945c5828d02aaf9d6da0d6291b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
name: Docker Image Scan
on:
  push:
    branches: [ main ]
    tags: [ 'v*' ]
  pull_request:
    branches: [ main ]

jobs:
  docker-build:
    permissions:
      security-events: write
    runs-on: ubuntu-latest
    env:
      DOCKER_BUILDKIT: 1
      DOCKER_CLI_EXPERIMENTAL: enabled
    steps:
    - uses: actions/checkout@v4
    - name: Quick build (linux/alpine only)
      run: |
        docker build --target gomplate-alpine -t gomplate .
    - name: Run Trivy vulnerability scanner (table output)
      uses: aquasecurity/trivy-action@master
      with:
        image-ref: gomplate
        format: table
        exit-code: 1
        ignore-unfixed: true
        vuln-type: os,library
        severity: CRITICAL,HIGH
    - name: Run Trivy vulnerability scanner
      uses: aquasecurity/trivy-action@master
      with:
        image-ref: gomplate
        format: sarif
        output: trivy-results.sarif
        # exit-code: 1
        ignore-unfixed: true
        vuln-type: os,library
        # The SARIF format ignores severity and uploads all vulnerabilities for
        # later triage. The table-format step above is used to fail the build if
        # there are any critical or high vulnerabilities.
        # See https://github.com/aquasecurity/trivy-action/issues/95
        # severity: 'CRITICAL,HIGH'
        trivyignores: .trivyignore
    - name: Upload Trivy scan results to GitHub Security tab
      uses: github/codeql-action/upload-sarif@v3
      with:
        sarif_file: 'trivy-results.sarif'
      if: always() && github.repository == 'hairyhenderson/gomplate'