Skip to content

Commit

Permalink
add image scanning on pull_request
Browse files Browse the repository at this point in the history
Signed-off-by: zhzhuang-zju <[email protected]>
  • Loading branch information
zhzhuang-zju committed Dec 7, 2023
1 parent 6128367 commit 9299ae3
Showing 1 changed file with 21 additions and 5 deletions.
26 changes: 21 additions & 5 deletions .github/workflows/ci-image-scanning.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
name: image-scanning
on:
push:
push:
branches:
- master
pull_request:
branches:
- master
jobs:
use-trivy-to-scan-image:
name: image-scanning
Expand All @@ -24,27 +29,38 @@ jobs:
steps:
- name: checkout code
uses: actions/checkout@v3
with:
# Number of commits to fetch. 0 indicates all history for all branches and tags.
# We need to guess version via git tags.
fetch-depth: 0
- name: install Go
uses: actions/setup-go@v3
with:
go-version: 1.20.11
- name: Build an image from Dockerfile
run: |
export VERSION="latest"
export REGISTRY="docker.io/karmada"
make image-${{ matrix.target }}
- name: Run Trivy vulnerability scanner
if: ${{ github.event_name == 'push' }}
uses: aquasecurity/[email protected]
with:
image-ref: 'docker.io/karmada/${{ matrix.target }}:latest'
format: 'sarif'
ignore-unfixed: true
vuln-type: 'os,library'
output: 'trivy-results.sarif'
- name: Upload Trivy scan results to GitHub Security tab
if: ${{ github.event_name == 'push' }}
uses: github/codeql-action/upload-sarif@v2
with:
sarif_file: 'trivy-results.sarif'
- name: display scan results
if: ${{ github.event_name == 'pull_request' }}
uses: aquasecurity/[email protected]
with:
image-ref: 'docker.io/karmada/${{ matrix.target }}:latest'
format: 'table'
ignore-unfixed: true
vuln-type: 'os,library'
- name: Upload Trivy scan results to GitHub Security tab
uses: github/codeql-action/upload-sarif@v2
with:
sarif_file: 'trivy-results.sarif'

0 comments on commit 9299ae3

Please sign in to comment.