6 Commits

Author SHA1 Message Date
755e1d877b chore(deps): update https://gitea.t000-n.de/t.behrendt/trivy-actions action to v1.4.7 (#10)
Some checks failed
CD / Release (push) Has been cancelled
This PR contains the following updates:

| Package | Type | Update | Change |
|---|---|---|---|
| [https://gitea.t000-n.de/t.behrendt/trivy-actions](https://gitea.t000-n.de/t.behrendt/trivy-actions) | action | patch | `1.4.5` → `1.4.7` |

---

### Release Notes

<details>
<summary>t.behrendt/trivy-actions (https://gitea.t000-n.de/t.behrendt/trivy-actions)</summary>

### [`v1.4.7`](https://gitea.t000-n.de/t.behrendt/trivy-actions/compare/1.4.6...1.4.7)

[Compare Source](https://gitea.t000-n.de/t.behrendt/trivy-actions/compare/1.4.6...1.4.7)

### [`v1.4.6`](https://gitea.t000-n.de/t.behrendt/trivy-actions/compare/1.4.5...1.4.6)

[Compare Source](https://gitea.t000-n.de/t.behrendt/trivy-actions/compare/1.4.5...1.4.6)

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box

---

This PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0My41LjQiLCJ1cGRhdGVkSW5WZXIiOiI0My41LjQiLCJ0YXJnZXRCcmFuY2giOiJtYWluIiwibGFiZWxzIjpbImFjdGlvbiIsImRlcHMiXX0=-->

Reviewed-on: t.behrendt/trivy-workflows#10
Reviewed-by: t.behrendt <t.behrendt@noreply.localhost>
Co-authored-by: Renovate Bot <renovate@t00n.de>
Co-committed-by: Renovate Bot <renovate@t00n.de>
2026-03-15 21:52:47 +01:00
21d6d0a0d4 chore(deps): update https://gitea.t000-n.de/t.behrendt/actions action to v0.1.5 (#6)
All checks were successful
CD / Release (push) Successful in 6s
This PR contains the following updates:

| Package | Type | Update | Change | Pending |
|---|---|---|---|---|
| [https://gitea.t000-n.de/t.behrendt/actions](https://gitea.t000-n.de/t.behrendt/actions) | action | patch | `0.1.4` → `0.1.5` | `0.2.1` (+3) |

---

### Release Notes

<details>
<summary>t.behrendt/actions (https://gitea.t000-n.de/t.behrendt/actions)</summary>

### [`v0.1.5`](https://gitea.t000-n.de/t.behrendt/actions/compare/0.1.4...0.1.5)

[Compare Source](https://gitea.t000-n.de/t.behrendt/actions/compare/0.1.4...0.1.5)

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box

---

This PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0My41LjQiLCJ1cGRhdGVkSW5WZXIiOiI0My41LjQiLCJ0YXJnZXRCcmFuY2giOiJtYWluIiwibGFiZWxzIjpbImFjdGlvbiIsImRlcHMiXX0=-->

Reviewed-on: t.behrendt/trivy-workflows#6
Reviewed-by: t.behrendt <t.behrendt@noreply.localhost>
Co-authored-by: Renovate Bot <renovate@t00n.de>
Co-committed-by: Renovate Bot <renovate@t00n.de>
2026-02-27 19:07:41 +01:00
a1df1e3972 chore(deps): update https://gitea.t000-n.de/t.behrendt/conventional-semantic-git-tag-increment action to v0.1.29 (#7)
All checks were successful
CD / Release (push) Successful in 2m42s
This PR contains the following updates:

| Package | Type | Update | Change |
|---|---|---|---|
| [https://gitea.t000-n.de/t.behrendt/conventional-semantic-git-tag-increment](https://gitea.t000-n.de/t.behrendt/conventional-semantic-git-tag-increment) | action | patch | `0.1.28` → `0.1.29` |

---

### Release Notes

<details>
<summary>t.behrendt/conventional-semantic-git-tag-increment (https://gitea.t000-n.de/t.behrendt/conventional-semantic-git-tag-increment)</summary>

### [`v0.1.29`](https://gitea.t000-n.de/t.behrendt/conventional-semantic-git-tag-increment/compare/0.1.28...0.1.29)

[Compare Source](https://gitea.t000-n.de/t.behrendt/conventional-semantic-git-tag-increment/compare/0.1.28...0.1.29)

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box

---

This PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0My41LjQiLCJ1cGRhdGVkSW5WZXIiOiI0My41LjQiLCJ0YXJnZXRCcmFuY2giOiJtYWluIiwibGFiZWxzIjpbImFjdGlvbiIsImRlcHMiXX0=-->

Reviewed-on: t.behrendt/trivy-workflows#7
Reviewed-by: t.behrendt <t.behrendt@noreply.localhost>
Co-authored-by: Renovate Bot <renovate@t00n.de>
Co-committed-by: Renovate Bot <renovate@t00n.de>
2026-02-27 19:03:54 +01:00
96f653553f feat: add fs scan (#3)
All checks were successful
CD / Release (push) Successful in 21s
Reviewed-on: t.behrendt/trivy-workflows#3
Co-authored-by: Timo Behrendt <t.behrendt@t00n.de>
Co-committed-by: Timo Behrendt <t.behrendt@t00n.de>
2026-02-26 22:06:28 +01:00
18b347368a chore: bump trivy-actions (#4)
All checks were successful
CD / Release (push) Successful in 5s
Reviewed-on: t.behrendt/trivy-workflows#4
Co-authored-by: Timo Behrendt <t.behrendt@t00n.de>
Co-committed-by: Timo Behrendt <t.behrendt@t00n.de>
2026-02-26 21:54:54 +01:00
4b9138d8f8 feat: add run-trivy-scan (#2)
All checks were successful
CD / Release (push) Successful in 22s
Reviewed-on: t.behrendt/trivy-workflows#2
Co-authored-by: Timo Behrendt <t.behrendt@t00n.de>
Co-committed-by: Timo Behrendt <t.behrendt@t00n.de>
2026-02-25 22:30:42 +01:00
4 changed files with 288 additions and 5 deletions

View File

@@ -15,10 +15,10 @@ jobs:
fetch-depth: 0
- name: Increment tag
id: tag
uses: https://gitea.t000-n.de/t.behrendt/conventional-semantic-git-tag-increment@8d27605e8e6b2990e92e5aa75d703e602b8c4b2a # 0.1.28
uses: https://gitea.t000-n.de/t.behrendt/conventional-semantic-git-tag-increment@41b7e04221df8a033bec841d40a097b76e5f67ff # 0.1.29
with:
token: ${{ secrets.GITEA_TOKEN }}
- name: Push tag
uses: https://gitea.t000-n.de/t.behrendt/actions/release-git-tag@8973a9f9ff51c16b937364e0047e7ad07e937d3f # 0.1.4
uses: https://gitea.t000-n.de/t.behrendt/actions/release-git-tag@74e7be819ecfc1a8d3e3fcf679e8f3e0a7065343 # 0.1.5
with:
tag: ${{ steps.tag.outputs.new-tag }}

View File

@@ -13,11 +13,11 @@ jobs:
fetch-depth: 0
- name: Increment tag
id: tag
uses: https://gitea.t000-n.de/t.behrendt/conventional-semantic-git-tag-increment@8d27605e8e6b2990e92e5aa75d703e602b8c4b2a # 0.1.28
uses: https://gitea.t000-n.de/t.behrendt/conventional-semantic-git-tag-increment@41b7e04221df8a033bec841d40a097b76e5f67ff # 0.1.29
with:
token: ${{ secrets.GITEA_TOKEN }}
prerelease: true
- name: Push tag
uses: https://gitea.t000-n.de/t.behrendt/actions/release-git-tag@8973a9f9ff51c16b937364e0047e7ad07e937d3f # 0.1.4
uses: https://gitea.t000-n.de/t.behrendt/actions/release-git-tag@74e7be819ecfc1a8d3e3fcf679e8f3e0a7065343 # 0.1.5
with:
tag: ${{ steps.tag.outputs.new-tag }}

View File

@@ -0,0 +1,192 @@
name: Run Trivy Scan
on:
workflow_call:
inputs:
scan-config:
description: "Run Trivy config scan (repository root)."
required: false
type: boolean
default: false
scan-images:
description: "Run Trivy image scan on images from image-scan-files."
required: false
type: boolean
default: false
image-scan-files:
description: "YAML list of files to extract container images from. Used when scan-images is true."
required: false
type: string
default: ""
trivy-server-url:
description: "Optional Trivy server URL for image scan."
required: false
type: string
default: ""
scan-fs:
description: "Run Trivy file system scan on the repository root."
required: false
type: boolean
default: false
outputs:
merged-sarif-artifact:
description: "Artifact name containing the merged SARIF file (download this artifact; file inside is merged-sarif.json)."
value: ${{ jobs.merge.outputs.merged-sarif-artifact }}
merged-sarif-path:
description: "Path to the merged SARIF file inside the artifact (merged-sarif.json)."
value: ${{ jobs.merge.outputs.merged-sarif-path }}
jobs:
config-scan:
if: inputs.scan-config
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- uses: https://gitea.t000-n.de/t.behrendt/trivy-actions/setup-trivy@a6508d695d7bb6137f14372392d5c312c98225cf # 1.4.7
- uses: https://gitea.t000-n.de/t.behrendt/trivy-actions/setup-db@a6508d695d7bb6137f14372392d5c312c98225cf # 1.4.7
- run: |
trivy config --cache-dir "$TRIVY_CACHE_DIR" --exit-code 0 --format sarif --output config-sarif.json .
env:
TRIVY_CACHE_DIR: ${{ runner.temp }}/trivy
- uses: https://github.com/ChristopherHX/gitea-upload-artifact@v4
with:
name: config-sarif
path: config-sarif.json
image-scan:
if: inputs.scan-images
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- uses: https://gitea.t000-n.de/t.behrendt/trivy-actions/setup-trivy@a6508d695d7bb6137f14372392d5c312c98225cf # 1.4.7
- uses: https://gitea.t000-n.de/t.behrendt/trivy-actions/setup-db@a6508d695d7bb6137f14372392d5c312c98225cf # 1.4.7
- name: Get images from files
id: get-images
uses: https://gitea.t000-n.de/t.behrendt/trivy-actions/get-images-from-files@a6508d695d7bb6137f14372392d5c312c98225cf # 1.4.7
with:
files: ${{ inputs.image-scan-files }}
- name: Pull images
if: steps.get-images.outputs.images != '[]'
run: |
set -e
images='${{ steps.get-images.outputs.images }}'
for img in $(echo "$images" | jq -r '.[]'); do
docker pull "$img"
done
- name: Scan images
id: scan
if: steps.get-images.outputs.images != '[]'
run: |
set -e
images='${{ steps.get-images.outputs.images }}'
count=$(echo "$images" | jq 'length')
if [ "$count" -eq 0 ]; then
echo "count=0" >> "$GITHUB_OUTPUT"
exit 0
fi
i=0
server="${{ inputs.trivy-server-url }}"
for img in $(echo "$images" | jq -r '.[]'); do
args=(image --cache-dir "$TRIVY_CACHE_DIR" --exit-code 0 --scanners vuln --format sarif --output "sarif-image-${i}.json" "$img")
[ -n "$server" ] && args+=(--server "$server")
trivy "${args[@]}"
i=$((i + 1))
done
{
echo "files<<EOF"
for j in $(seq 0 $((i - 1))); do echo " - sarif-image-${j}.json"; done
echo "EOF"
} >> $GITHUB_OUTPUT
echo "count=$i" >> $GITHUB_OUTPUT
env:
TRIVY_CACHE_DIR: ${{ runner.temp }}/trivy
- name: Merge image SARIF files
if: steps.get-images.outputs.images != '[]' && steps.scan.outputs.count != '0'
uses: https://gitea.t000-n.de/t.behrendt/trivy-actions/merge-sarif-files@a6508d695d7bb6137f14372392d5c312c98225cf # 1.4.7
with:
files: ${{ steps.scan.outputs.files }}
output-file: image-sarif.json
- name: Ensure image SARIF exists (no images case)
if: steps.get-images.outputs.images == '[]' || steps.scan.outputs.count == '0'
run: |
echo '{"version":"2.1.0","$schema":"https://raw.githubusercontent.com/oasis-tcs/sarif-spec/master/Schemata/sarif-schema-2.1.0.json","runs":[]}' > image-sarif.json
- uses: https://github.com/ChristopherHX/gitea-upload-artifact@v4
with:
name: image-sarif
path: image-sarif.json
fs-scan:
if: inputs.scan-fs
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- uses: https://gitea.t000-n.de/t.behrendt/trivy-actions/setup-trivy@a6508d695d7bb6137f14372392d5c312c98225cf # 1.4.7
- uses: https://gitea.t000-n.de/t.behrendt/trivy-actions/setup-db@a6508d695d7bb6137f14372392d5c312c98225cf # 1.4.7
- run: |
server="${{ inputs.trivy-server-url }}"
args=(fs --cache-dir "$TRIVY_CACHE_DIR" --exit-code 0 --format sarif --output fs-sarif.json --scanners vuln .)
[ -n "$server" ] && args+=(--server "$server")
trivy "${args[@]}"
env:
TRIVY_CACHE_DIR: ${{ runner.temp }}/trivy
- uses: https://github.com/ChristopherHX/gitea-upload-artifact@v4
with:
name: fs-sarif
path: fs-sarif.json
merge:
runs-on: ubuntu-latest
needs: [config-scan, image-scan, fs-scan]
if: always() && (needs.config-scan.result == 'success' || needs.config-scan.result == 'skipped') && (needs.image-scan.result == 'success' || needs.image-scan.result == 'skipped') && (inputs.scan-config || inputs.scan-images)
outputs:
merged-sarif-artifact: ${{ steps.outputs.outputs.merged-sarif-artifact }}
merged-sarif-path: ${{ steps.outputs.outputs.merged-sarif-path }}
steps:
- name: Require at least one scan
if: ${{ !inputs.scan-config && !inputs.scan-images }}
run: |
echo "Enable scan-config and/or scan-images (and provide image-scan-files for image scan)."
exit 1
- name: Download config SARIF
if: inputs.scan-config
uses: https://github.com/ChristopherHX/gitea-download-artifact@v4
with:
name: config-sarif
path: config-sarif-artifact
- name: Download image SARIF
if: inputs.scan-images
uses: https://github.com/ChristopherHX/gitea-download-artifact@v4
with:
name: image-sarif
path: image-sarif-artifact
- name: Build merge file list
id: file-list
run: |
files=""
if [ "${{ inputs.scan-config }}" = "true" ] && [ -f config-sarif-artifact/config-sarif.json ]; then
files="- config-sarif-artifact/config-sarif.json"
fi
if [ "${{ inputs.scan-images }}" = "true" ] && [ -f image-sarif-artifact/image-sarif.json ]; then
[ -n "$files" ] && files="$files"$'\n'" - image-sarif-artifact/image-sarif.json" || files="- image-sarif-artifact/image-sarif.json"
fi
if [ "${{ inputs.scan-fs }}" = "true" ] && [ -f fs-sarif-artifact/fs-sarif.json ]; then
[ -n "$files" ] && files="$files"$'\n'" - fs-sarif-artifact/fs-sarif.json" || files="- fs-sarif-artifact/fs-sarif.json"
fi
echo "files<<EOF" >> "$GITHUB_OUTPUT"
echo "$files" >> "$GITHUB_OUTPUT"
echo "EOF" >> "$GITHUB_OUTPUT"
- name: Merge SARIF files
id: merge-step
uses: https://gitea.t000-n.de/t.behrendt/trivy-actions/merge-sarif-files@a6508d695d7bb6137f14372392d5c312c98225cf # 1.4.7
with:
files: ${{ steps.file-list.outputs.files }}
output-file: merged-sarif.json
- name: Set outputs
id: outputs
run: |
echo "merged-sarif-artifact=merged-sarif" >> "$GITHUB_OUTPUT"
echo "merged-sarif-path=merged-sarif.json" >> "$GITHUB_OUTPUT"
- uses: https://github.com/ChristopherHX/gitea-upload-artifact@v4
with:
name: merged-sarif
path: merged-sarif.json

View File

@@ -1,2 +1,93 @@
# trivy-workflows
# Trivy Workflows
## Run Trivy Scan (reusable workflow)
Reusable workflow that optionally runs Trivy config and/or image scan, merges the SARIF results, and exposes the merged file as an artifact. It does **not** upload to TAS; callers download the artifact and use it (e.g. with `tas-upload-sarif`).
**Workflow file:** [../.gitea/workflows/run-trivy-scan.yaml](../.gitea/workflows/run-trivy-scan.yaml)
## Usage
### Call from another workflow (same repo)
```yaml
jobs:
trivy:
uses: ./.gitea/workflows/run-trivy-scan.yaml
with:
scan-config: true
scan-images: true
image-scan-files: |
- k8s/31_deployment_redis.yaml
- k8s/32_deployment_gitea.yaml
- dockers/runner/compose.yaml
trivy-server-url: ${{ vars.TRIVY_SERVER_URL }}
use-sarif:
needs: trivy
runs-on: ubuntu-latest
steps:
- name: Download merged SARIF
uses: https://github.com/ChristopherHX/gitea-download-artifact@v4
with:
name: ${{ needs.trivy.outputs.merged-sarif-artifact }}
path: sarif
# Path to file: sarif/${{ needs.trivy.outputs.merged-sarif-path }}
# - uses: .../tas-upload-sarif@...
# with:
# sarif-file: sarif/${{ needs.trivy.outputs.merged-sarif-path }}
```
### Call from another repository
Use the **full workflow path** including `.gitea/workflows/` and the filename. Gitea does not accept a bare repo path like `.../trivy-actions/run-trivy-scan@ref`.
**With absolute URL:**
```yaml
jobs:
trivy:
uses: https://gitea.t000-n.de/t.behrendt/trivy-actions/.gitea/workflows/run-trivy-scan.yaml@1.4.5
with:
ref: 1.4.5 # use same ref as in 'uses' so actions load from trivy-actions
scan-config: true
scan-images: true
image-scan-files: |
- k8s/31_deployment_redis.yaml
trivy-server-url: ${{ vars.TRIVY_SERVER_URL }}
```
**With owner/repo path** (same server as the caller):
```yaml
jobs:
trivy:
uses: t.behrendt/trivy-actions/.gitea/workflows/run-trivy-scan.yaml@1.4.5
with:
ref: 1.4.5 # use same ref as in 'uses'
scan-config: true
scan-images: true
image-scan-files: |
- k8s/31_deployment_redis.yaml
```
When calling from another repo, pass **`ref`** with the same ref as in the workflow path (e.g. `@1.4.5` or commit SHA). The workflow checks out trivy-actions at that ref into `trivy-actions/` and then uses the actions from that checkout (e.g. `./trivy-actions/setup-trivy`).
### Inputs
| Input | Type | Default | Description |
| ------------------- | ------- | ------- | ----------- |
| `scan-config` | boolean | false | Run Trivy config scan on the repository root. |
| `scan-images` | boolean | false | Run Trivy image scan on images from `image-scan-files`. |
| `image-scan-files` | string | "" | YAML list of files to extract container images from. |
| `trivy-server-url` | string | "" | Optional Trivy server URL for image scan. |
| `ref` | string | "main" | Git ref to checkout (branch, tag, or SHA); use the same ref as in the workflow path when calling from another repo. |
| `repository-url` | string | "https://gitea.t000-n.de/t.behrendt/trivy-actions.git" | Clone URL for trivy-actions; for private repos use a URL with token or SSH. |
At least one of `scan-config` or `scan-images` must be true. If `scan-images` is true, set `image-scan-files`.
### Outputs
| Output | Description |
| ------------------------ | ----------- |
| `merged-sarif-artifact` | Artifact name to pass to `download-artifact` (e.g. `merged-sarif`). |
| `merged-sarif-path` | Path to the file inside that artifact (e.g. `merged-sarif.json`). |
After downloading the artifact, the merged SARIF file is at `<download-path>/${{ needs.<job>.outputs.merged-sarif-path }}`.