Skip to content

[DPE-2707] Create trivy scanner #4

[DPE-2707] Create trivy scanner

[DPE-2707] Create trivy scanner #4

Workflow file for this run

name: trivy
on:
push:
branches:
- main
pull_request:
jobs:
build:
uses: ./.github/workflows/build.yaml
scan:
needs: build
runs-on: ubuntu-20.04
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Setup Docker
run: |
sudo snap install docker
sudo addgroup --system docker; sudo adduser $USER docker
newgrp docker
sudo snap disable docker; sudo snap enable docker
- name: Install skopeo
run: |
sudo snap install --devmode --channel edge skopeo
- name: Install yq
run: |
sudo snap install yq
- uses: actions/download-artifact@v3
with:
name: charmed-kafka
- name: Import locally
run: |
version=$(yq '(.version|split("-"))[0]' rockcraft.yaml)
base=$(yq '(.base|split(":"))[1]' rockcraft.yaml)
risk=edge
tag=${version}-${base}_${risk}
sudo skopeo --insecure-policy copy \
oci-archive:charmed-kafka_${tag}_amd64.rock \
docker-daemon:$USER/charmed-kafka:test
- name: Run Trivy vulnerability scanner
uses: aquasecurity/trivy-action@master
with:
image-ref: '$USER/charmed-kafka:test'
format: 'sarif'
output: 'trivy-results.sarif'
- name: Upload Trivy scan results to GitHub Security tab
uses: github/codeql-action/upload-sarif@v2
if: always()
with:
sarif_file: 'trivy-results.sarif'