Skip to content

Commit

Permalink
ci: Keep Trivy cache up-to-date on default branch
Browse files Browse the repository at this point in the history
  • Loading branch information
SanjayVas committed Oct 24, 2024
1 parent d41374d commit 0e9bd6c
Showing 1 changed file with 43 additions and 0 deletions.
43 changes: 43 additions & 0 deletions .github/workflows/update-trivy-cache.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: Update Trivy cache

on:
schedule:
- cron: '0 5 * * *' # Night in America/Los_Angeles, before deploy-nightly.
workflow_dispatch:
pull_request:
branches:
- main

jobs:
update-trivy-cache:
runs-on: ubuntu-latest
env:
TRIVY_CACHE_PATH: .cache/trivy
steps:
- uses: oras-project/setup-oras@v1

- name: Get current date
id: get-date
run: echo "date=$(date +'%Y-%m-%d')" >> "$GITHUB_OUTPUT"

- name: Download vulnerability DB
run: oras pull ghcr.io/aquasecurity/trivy-db:2

- name: Download Java DB
run: oras pull ghcr.io/aquasecurity/trivy-java-db:1

- name: Extract vulnerability DB
run: |
mkdir -p "$TRIVY_CACHE_PATH/db"
tar -xf db.tar.gz -C "$TRIVY_CACHE_PATH/db"
- name: Extract Java DB
run: |
mkdir -p "$TRIVY_CACHE_PATH/java-db"
tar -xf javadb.tar.gz -C "$TRIVY_CACHE_PATH/java-db"
- name: Save cache
uses: actions/cache/save@v4
with:
path: ${{ env.TRIVY_CACHE_PATH }}
key: cache-trivy-${{ steps.get-date.outputs.date }}

0 comments on commit 0e9bd6c

Please sign in to comment.