Skip to content

Commit

Permalink
ci: add cron job to cache trivy db (#283)
Browse files Browse the repository at this point in the history
Signed-off-by: Binbin Li <[email protected]>
  • Loading branch information
binbin-li authored Nov 6, 2024
1 parent 5d6d5b8 commit 78dd02f
Showing 1 changed file with 4 additions and 15 deletions.
19 changes: 4 additions & 15 deletions .github/workflows/scan-vulns.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,13 @@ jobs:
check-latest: true
- uses: golang/govulncheck-action@b625fbe08f3bccbe446d94fbf87fcc875a4f50ee # v1.0.4

restore_trivy_cache:
uses: ./.github/workflows/restore-trivy-cache.yml

scan_vulnerabilities:
name: "[Trivy] Scan for vulnerabilities"
runs-on: ubuntu-22.04
needs: ["restore_trivy_cache"]
timeout-minutes: 15
env:
TRIVY_VERSION: 0.49.1
Expand All @@ -54,21 +58,6 @@ jobs:
wget https://github.com/aquasecurity/trivy/releases/download/v${{ env.TRIVY_VERSION }}/trivy_${{ env.TRIVY_VERSION }}_Linux-64bit.tar.gz
tar zxvf trivy_${{ env.TRIVY_VERSION }}_Linux-64bit.tar.gz
echo "$(pwd)" >> $GITHUB_PATH
- name: Get current date
id: date
run: echo "date=$(date +'%Y-%m-%d')" >> $GITHUB_OUTPUT

- name: Restore trivy cache directory
uses: actions/cache/restore@6849a6489940f00c2f30c0fb92c6274307ccb58a # v4.1.2
with:
path: ${{ github.workspace }}/.cache/trivy
key: cache-trivy-${{ steps.date.outputs.date }}

- name: Set up trivy cache directory
run: |
mkdir -p ~/.cache/trivy
cp -r ${{ github.workspace }}/.cache/trivy/db ~/.cache/trivy
- name: Run trivy on git repository
run: |
Expand Down

0 comments on commit 78dd02f

Please sign in to comment.