Add reusable Docker build, Trivy scan and push workflow
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
commit
8228a19251
2 files changed
+202
No files matched your search
@@ -0,0 +1,74 @@
|
||||
# CI workflows
|
||||
|
||||
Shared Gitea Actions workflows. Repos call them instead of keeping their own copy.
|
||||
|
||||
## docker-build.yml
|
||||
|
||||
Builds the repo's Docker image, scans it with Trivy, and pushes it to
|
||||
`git.hin-fort.ch/<owner>/<repo>` only if the scan passes.
|
||||
|
||||
### Usage
|
||||
|
||||
Add `.gitea/workflows/build.yml` to the repo:
|
||||
|
||||
```yaml
|
||||
name: Build
|
||||
on:
|
||||
push:
|
||||
branches: [main]
|
||||
tags: ['v*', '[0-9]*']
|
||||
workflow_dispatch:
|
||||
jobs:
|
||||
build:
|
||||
uses: ci/workflows/.gitea/workflows/docker-build.yml@v1
|
||||
secrets: inherit
|
||||
```
|
||||
|
||||
For x64 and arm64 (Raspberry Pi), add:
|
||||
|
||||
```yaml
|
||||
with:
|
||||
platforms: linux/amd64,linux/arm64
|
||||
```
|
||||
|
||||
### Inputs
|
||||
|
||||
| Input | Default | Description |
|
||||
|---|---|---|
|
||||
| `platforms` | `linux/amd64` | Comma-separated target platforms. Any `arm` platform enables QEMU emulation. |
|
||||
| `context` | `.` | Docker build context. |
|
||||
| `file` | `<context>/Dockerfile` | Path to the Dockerfile. |
|
||||
| `severity` | `CRITICAL,HIGH` | Severities that fail the build. Vulnerabilities without a fixed version never fail it. |
|
||||
| `runs-on` | `linux-amd64` | Runner label. |
|
||||
|
||||
### Required secrets
|
||||
|
||||
Set these on the repo's organisation (or on the repo):
|
||||
|
||||
- `REGISTRY_TOKEN`: token with write access to the package registry.
|
||||
- `TRIVY_TOKEN`: token of the Trivy server.
|
||||
|
||||
Optional variable `TRIVY_SERVER` overrides the Trivy server address
|
||||
(default `http://localhost:4954`).
|
||||
|
||||
### Accepting a vulnerability
|
||||
|
||||
If a finding can't be fixed yet, add its ID to a `.trivyignore` file in the
|
||||
repo root, with a reason:
|
||||
|
||||
```
|
||||
# No fixed upstream release yet; not reachable in our usage. Review 2026-12.
|
||||
CVE-2026-12345
|
||||
```
|
||||
|
||||
### Tags
|
||||
|
||||
Repos reference `@v1`. Test changes on one repo by pointing it at a branch or
|
||||
commit, then move the `v1` tag:
|
||||
|
||||
```sh
|
||||
git tag -f v1 && git push -f origin v1
|
||||
```
|
||||
|
||||
Upgrading Trivy: change `TRIVY_IMAGE` in `docker-build.yml` and the image of
|
||||
the `Gitea-Trivy` container to the same version.
|
||||
Reference in new issue
Block a user