Skip to content

Commit

Permalink
ci: redo caching; do not scan for secrets
Browse files Browse the repository at this point in the history
  • Loading branch information
sjinks committed Sep 30, 2024
1 parent 20180e4 commit 38ca30c
Showing 1 changed file with 31 additions and 4 deletions.
35 changes: 31 additions & 4 deletions .github/actions/build-docker-image/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -134,11 +134,21 @@ runs:
shell: bash
run: mkdir -p .cache/trivy/db

- name: Cache Trivy database
uses: actions/[email protected]
- name: Restore Trivy database
uses: actions/cache/restore@v4.0.2
with:
path: .cache/trivy/db
key: ${{ runner.os }}-trivy
key: trivy

- name: Calculate database hash
shell: bash
id: old_hash
run: |
if [ -f .cache/trivy/db/trivy.db ]; then
echo "hash=$(sha256sum -b .cache/trivy/db/trivy.db | awk '{print $1}')" >> "${GITHUB_OUTPUT}"
else
echo "hash=" >> "${GITHUB_OUTPUT}"
fi
- name: Security Scan
shell: bash
Expand All @@ -148,9 +158,26 @@ runs:
-v $(pwd)/.cache:/root/.cache \
-v $(pwd):/workdir \
-w /workdir \
aquasec/trivy:0.55.2 image --format json --ignore-unfixed --pkg-types os ${{ inputs.primaryTag }} --output trivy.json
aquasec/trivy:0.55.2 image --format json --ignore-unfixed --pkg-types os --scanners vuln ${{ inputs.primaryTag }} --output trivy.json
sudo chmod a+r -R .cache
- name: Calculate database hash
shell: bash
id: new_hash
run: |
if [ -f .cache/trivy/db/trivy.db ]; then
echo "hash=$(sha256sum -b .cache/trivy/db/trivy.db | awk '{print $1}')" >> "${GITHUB_OUTPUT}"
else
echo "hash=" >> "${GITHUB_OUTPUT}"
fi
- name: Cache Trivy database
uses: actions/cache/[email protected]
with:
path: .cache/trivy/db
key: trivy
if: steps.old_hash.outputs.hash != steps.new_hash.outputs.hash && steps.new_hash.outputs.hash != ''

- name: Print report
uses: docker://aquasec/trivy:0.55.2
with:
Expand Down

0 comments on commit 38ca30c

Please sign in to comment.