diff --git a/setup-trivy/action.yaml b/setup-trivy/action.yaml index 745583f..702e2d8 100644 --- a/setup-trivy/action.yaml +++ b/setup-trivy/action.yaml @@ -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