feat(setup-trivy)!: automatically determine arch

This commit is contained in:
2025-11-08 18:42:14 +01:00
parent 5d059afcc6
commit 32041e0a21
2 changed files with 11 additions and 34 deletions
+1 -4
View File
@@ -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 uses: your-username/trivy-actions@main/setup-trivy
with: with:
version: "v0.66.0" # Optional: Trivy version (default: v0.66.0) version: "v0.66.0" # Optional: Trivy version (default: v0.66.0)
architecture: "amd64" # Optional: amd64 or arm64 (default: amd64)
``` ```
### Complete Example ### Complete Example
@@ -31,7 +30,6 @@ jobs:
uses: your-username/trivy-actions@main/setup-trivy uses: your-username/trivy-actions@main/setup-trivy
with: with:
version: "v0.66.0" version: "v0.66.0"
architecture: "amd64"
- name: Scan for vulnerabilities - name: Scan for vulnerabilities
run: trivy fs . run: trivy fs .
``` ```
@@ -39,6 +37,5 @@ jobs:
## Inputs ## Inputs
| Input | Description | Required | Default | | Input | Description | Required | Default |
| -------------- | ----------------------------------------- | -------- | --------- | | --------- | ----------------------------------------- | -------- | --------- |
| `version` | Trivy version to download (e.g., v0.66.0) | No | `v0.66.0` | | `version` | Trivy version to download (e.g., v0.66.0) | No | `v0.66.0` |
| `architecture` | System architecture (amd64, arm64) | No | `amd64` |
+8 -28
View File
@@ -7,13 +7,9 @@ branding:
inputs: inputs:
version: version:
description: "Trivy version to download (e.g., v0.66.0)" description: "Trivy version to download (e.g., latest)"
required: false required: false
default: "v0.66.0" default: "v0.66.0"
architecture:
description: "System architecture (amd64, arm64)"
required: false
default: "amd64"
runs: runs:
using: "composite" using: "composite"
@@ -28,24 +24,18 @@ runs:
trivy-${{ inputs.version }}-${{ inputs.architecture }}- trivy-${{ inputs.version }}-${{ inputs.architecture }}-
trivy-${{ inputs.version }}- trivy-${{ inputs.version }}-
- name: Validate inputs - shell: bash
shell: bash
run: | run: |
set -e set -e
case "$(uname -m)" in
VERSION="${{ inputs.version }}" x86_64)
ARCH="${{ inputs.architecture }}" ARCH="64bit"
# Validate architecture
case "$ARCH" in
amd64|arm64)
;; ;;
*) aarch64)
echo "Error: Unsupported architecture '$ARCH'. Supported: amd64, arm64" ARCH="ARM64"
exit 1
;; ;;
esac esac
echo "ARCH=$ARCH" >> $GITHUB_OUTPUT
- name: Download and install Trivy - name: Download and install Trivy
if: steps.cache-trivy.outputs.cache-hit != 'true' if: steps.cache-trivy.outputs.cache-hit != 'true'
shell: bash shell: bash
@@ -53,16 +43,6 @@ runs:
set -e set -e
VERSION="${{ inputs.version }}" VERSION="${{ inputs.version }}"
ARCH="${{ inputs.architecture }}"
case "$ARCH" in
amd64)
ARCH="64bit"
;;
arm64)
ARCH="ARM64"
;;
esac
mkdir -p /usr/local/bin mkdir -p /usr/local/bin