Update Trivy Cache #129
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # https://github.com/aquasecurity/trivy-action?tab=readme-ov-file#updating-caches-in-the-default-branch | |
| name: Update Trivy Cache | |
| on: | |
| schedule: | |
| - cron: '0 0 * * *' # Run daily at midnight UTC | |
| workflow_dispatch: # Allow manual triggering | |
| jobs: | |
| update-trivy-db: | |
| runs-on: ubuntu-24.04 | |
| steps: | |
| - name: Install Trivy | |
| uses: aquasecurity/setup-trivy@3fb12ec12f41e471780db15c232d5dd185dcb514 # https://github.com/aquasecurity/setup-trivy/releases/tag/v0.2.6 | |
| - name: Get current date | |
| id: date | |
| run: echo "date=$(date +'%Y-%m-%d')" >> $GITHUB_OUTPUT | |
| - name: Download and extract the vulnerability DB | |
| run: | | |
| trivy --cache-dir ${{ github.workspace }}/.cache/trivy image --download-db-only | |
| - name: Cache DBs | |
| id: cache-dbs | |
| uses: actions/cache/save@668228422ae6a00e4ad889ee87cd7109ec5666a7 # https://github.com/actions/cache/releases/tag/v5.0.4 | |
| with: | |
| path: ${{ github.workspace }}/.cache/trivy | |
| key: cache-trivy-${{ steps.date.outputs.date }} |