feat(setup-trivy): use latest as default version (#15)
CD / Release (push) Successful in 11s

Using the "latest" released version of Trivy as the default version.
We always first resolve latest to an actual version to allow the cache to work properly.

Reviewed-on: t.behrendt/trivy-actions#15
Reviewed-by: branch-buddy <branch-buddy@t00n.de>
Co-authored-by: Timo Behrendt <t.behrendt@t00n.de>
Co-committed-by: Timo Behrendt <t.behrendt@t00n.de>
This commit was merged in pull request #15.
This commit is contained in:
2025-11-08 19:48:17 +01:00
committed by t.behrendt
parent 0c324d36cf
commit 8df2386e42
4 changed files with 19 additions and 16 deletions
+15 -4
View File
@@ -9,7 +9,7 @@ inputs:
version:
description: "Trivy version to download (e.g., latest)"
required: false
default: "v0.66.0"
default: "latest"
runs:
using: "composite"
@@ -27,21 +27,32 @@ runs:
;;
esac
echo "ARCH=$ARCH" >> $GITHUB_OUTPUT
- name: Resolve version
shell: bash
id: version
run: |
set -e
if [ "${{ inputs.version }}" = "latest" ]; then
VERSION=$(curl -s https://api.github.com/repos/aquasecurity/trivy/releases/latest | jq -r '.tag_name')
else
VERSION="${{ inputs.version }}"
fi
echo "VERSION=$VERSION" >> $GITHUB_OUTPUT
- name: Cache Trivy binary
id: cache-trivy
uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4
with:
path: /usr/local/bin/trivy
key: trivy-${{ inputs.version }}-${{ steps.arch.outputs.arch }}
key: trivy-${{ steps.version.outputs.version }}-${{ steps.arch.outputs.arch }}
restore-keys: |
trivy-${{ inputs.version }}-${{ steps.arch.outputs.arch }}
trivy-${{ steps.version.outputs.version }}-${{ steps.arch.outputs.arch }}
- name: Download and install Trivy
if: steps.cache-trivy.outputs.cache-hit != 'true'
shell: bash
run: |
set -e
VERSION="${{ inputs.version }}"
VERSION="${{ steps.version.outputs.version }}"
mkdir -p /usr/local/bin