Skip to content

Commit

Permalink
fix: conditionall cache if not exist yet
Browse files Browse the repository at this point in the history
Doc-only:true

Required-githooks: true

Signed-off-by: Tomasz Gromadzki <[email protected]>
  • Loading branch information
grom72 committed Oct 25, 2024
1 parent 7119e67 commit 373552e
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions .github/workflows/trivy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,21 +27,31 @@ jobs:
id: date
run: echo "date=$(date +'%Y-%m-%d')" >> $GITHUB_OUTPUT

- name: Download and extract the vulnerability DB
- id: db-downloaded
name: DB cached already
uses: actions/cache@v1

Check warning

Code scanning / Scorecard

Pinned-Dependencies Medium

score is 1: GitHub-owned GitHubAction not pinned by hash
Click Remediation section below to solve this issue
with:
path: ${{ github.workspace }}/.cache/trivy
key: cache-trivy-${{ steps.date.outputs.date }}

- if: ${{ steps.db-downloaded.outputs.cache-hit != 'true' }}
name: Download and extract the vulnerability DB
run: |
mkdir -p $GITHUB_WORKSPACE/.cache/trivy/db
oras pull ghcr.io/aquasecurity/trivy-db:2
tar -xzf db.tar.gz -C $GITHUB_WORKSPACE/.cache/trivy/db
rm db.tar.gz
- name: Download and extract the Java DB
- if: ${{ steps.db-downloaded.outputs.cache-hit != 'true' }}
name: Download and extract the Java DB
run: |
mkdir -p $GITHUB_WORKSPACE/.cache/trivy/java-db
oras pull ghcr.io/aquasecurity/trivy-java-db:1
tar -xzf javadb.tar.gz -C $GITHUB_WORKSPACE/.cache/trivy/java-db
rm javadb.tar.gz
- name: Cache DBs
- if: ${{ steps.db-downloaded.outputs.cache-hit != 'true' }}
name: Cache DBs
uses: actions/cache/save@v4

Check warning

Code scanning / Scorecard

Pinned-Dependencies Medium

score is 1: GitHub-owned GitHubAction not pinned by hash
Click Remediation section below to solve this issue
with:
path: ${{ github.workspace }}/.cache/trivy
Expand Down

0 comments on commit 373552e

Please sign in to comment.