Skip to content

Commit

Permalink
ci: cache Trivy database
Browse files Browse the repository at this point in the history
  • Loading branch information
sjinks committed Sep 30, 2024
1 parent b0447b4 commit 77d496a
Showing 1 changed file with 18 additions and 6 deletions.
24 changes: 18 additions & 6 deletions .github/actions/build-docker-image/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ runs:
registry: ${{ inputs.registry }}
username: ${{ inputs.username }}
password: ${{ inputs.password }}
if: ${{ inputs.push }}

- name: Build and push container image
uses: docker/build-push-action@v6
Expand Down Expand Up @@ -131,12 +130,25 @@ runs:
run: |
echo "filename=trivy-$(basename "${{ inputs.primaryTag }}" | tr '\\/:' '-').sarif" >> "${GITHUB_OUTPUT}"
- name: Security Scan
uses: docker://aquasec/trivy:0.55.2
- name: Create cache directory
shell: bash
run: mkdir -p .cache

- name: Cache Trivy database
uses: actions/[email protected]
with:
args: image --format json --ignore-unfixed --vuln-type os ${{ inputs.primaryTag }} --output trivy.json
env:
ACTIONS_RUNTIME_TOKEN: ${{ inputs.auth_token }}
path: .cache/trivy/db
key: ${{ runner.os }}-trivy

- name: Security Scan
shell: bash
run: |
docker run -it --rm \
-v /var/run/docker.sock:/var/run/docker.sock \
-v $(pwd)/.cache:/root/.cache \
-v $(pwd):/workdir \
-w /workdir \
aquasec/trivy:0.55.2 image --format json --ignore-unfixed --pkg-types os --registry-token=${{ inputs.auth_token }} ${{ inputs.primaryTag }} --output trivy.json
- name: Print report
uses: docker://aquasec/trivy:0.55.2
Expand Down

0 comments on commit 77d496a

Please sign in to comment.