name: "Setup Trivy DB" description: "Setup the trivy database, restoring from cache if available" author: "Timo Behrendt > $GITHUB_OUTPUT - name: Ensure Trivy cache directory exists shell: bash run: mkdir -p "${{ inputs.cache-dir }}" - id: restore-db uses: actions/cache@cdf6c1fa76f9f475f3d7449005a359c84ca0f306 # v5 with: path: ${{ inputs.cache-dir }} key: trivy-db-${{ steps.current-date.outputs.current-date }} restore-keys: | trivy-db-${{ steps.current-date.outputs.current-date }} - if: steps.restore-db.outputs.cache-hit != 'true' shell: bash run: | docker run --rm \ --name trivy-db-download \ --user "$(id -u):$(id -g)" \ --read-only \ --env-file /dev/null \ --cap-drop ALL \ --pids-limit 64 \ --memory=512m \ --memory-swap=512m \ --cpus=1 \ --ipc private \ --cgroupns private \ --security-opt no-new-privileges \ --security-opt apparmor=docker-default \ --tmpfs /tmp:rw,noexec,nosuid,nodev,size=1g \ --mount type=bind,src=${{ inputs.cache-dir }},dst=/cache \ ${{ inputs.trivy-version }} fs --download-db-only --cache-dir /cache --offline-scan --exit-code 0