From 32041e0a21d9e7113f3746d3756ec5d4981cec70 Mon Sep 17 00:00:00 2001 From: Timo Behrendt Date: Sat, 8 Nov 2025 18:42:14 +0100 Subject: [PATCH] feat(setup-trivy)!: automatically determine arch --- setup-trivy/README.md | 9 +++------ setup-trivy/action.yaml | 36 ++++++++---------------------------- 2 files changed, 11 insertions(+), 34 deletions(-) diff --git a/setup-trivy/README.md b/setup-trivy/README.md index ef04950..6835c39 100644 --- a/setup-trivy/README.md +++ b/setup-trivy/README.md @@ -11,7 +11,6 @@ A reusable Gitea Action that downloads and sets up the Trivy binary for vulnerab uses: your-username/trivy-actions@main/setup-trivy with: version: "v0.66.0" # Optional: Trivy version (default: v0.66.0) - architecture: "amd64" # Optional: amd64 or arm64 (default: amd64) ``` ### Complete Example @@ -31,14 +30,12 @@ jobs: uses: your-username/trivy-actions@main/setup-trivy with: version: "v0.66.0" - architecture: "amd64" - name: Scan for vulnerabilities run: trivy fs . ``` ## Inputs -| Input | Description | Required | Default | -| -------------- | ----------------------------------------- | -------- | --------- | -| `version` | Trivy version to download (e.g., v0.66.0) | No | `v0.66.0` | -| `architecture` | System architecture (amd64, arm64) | No | `amd64` | +| Input | Description | Required | Default | +| --------- | ----------------------------------------- | -------- | --------- | +| `version` | Trivy version to download (e.g., v0.66.0) | No | `v0.66.0` | diff --git a/setup-trivy/action.yaml b/setup-trivy/action.yaml index a9f18af..c266cc1 100644 --- a/setup-trivy/action.yaml +++ b/setup-trivy/action.yaml @@ -7,13 +7,9 @@ branding: inputs: version: - description: "Trivy version to download (e.g., v0.66.0)" + description: "Trivy version to download (e.g., latest)" required: false default: "v0.66.0" - architecture: - description: "System architecture (amd64, arm64)" - required: false - default: "amd64" runs: using: "composite" @@ -28,24 +24,18 @@ runs: trivy-${{ inputs.version }}-${{ inputs.architecture }}- trivy-${{ inputs.version }}- - - name: Validate inputs - shell: bash + - shell: bash run: | set -e - - VERSION="${{ inputs.version }}" - ARCH="${{ inputs.architecture }}" - - # Validate architecture - case "$ARCH" in - amd64|arm64) + case "$(uname -m)" in + x86_64) + ARCH="64bit" ;; - *) - echo "Error: Unsupported architecture '$ARCH'. Supported: amd64, arm64" - exit 1 + aarch64) + ARCH="ARM64" ;; esac - + echo "ARCH=$ARCH" >> $GITHUB_OUTPUT - name: Download and install Trivy if: steps.cache-trivy.outputs.cache-hit != 'true' shell: bash @@ -53,16 +43,6 @@ runs: set -e VERSION="${{ inputs.version }}" - ARCH="${{ inputs.architecture }}" - - case "$ARCH" in - amd64) - ARCH="64bit" - ;; - arm64) - ARCH="ARM64" - ;; - esac mkdir -p /usr/local/bin