A repo and its push mirrors build the same commit at the same time on
the same Docker daemon. With the SHA in the temporary tag, one job
removed the image the other was still scanning ("No such image:
trivy-scan:<sha>-linux-amd64" in kj/scm-manager).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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
For a new repo, create it from the
template-docker
template, which already contains this. For an existing repo, add
.gitea/workflows/build.yml:
name: Build
on:
push:
branches: [main]
tags: ['v*', '[0-9]*']
schedule:
- cron: '0 19 * * 5' # Fri 20:00 CET / 21:00 CEST (cron is UTC)
workflow_dispatch:
jobs:
build:
uses: ci/workflows/.gitea/workflows/docker-build.yml@main
with:
# Weekly rebuilds skip the cache so base image and package updates get in.
no-cache: ${{ gitea.event_name == 'schedule' }}
secrets: inherit
The weekly rebuild catches new CVEs in images whose code hasn't changed.
For x64 and arm64 (Raspberry Pi), add:
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. |
build-args |
Extra build args, one NAME=value per line, e.g. APP_VERSION=${{ gitea.sha }}. Used for both the scanned and the pushed build. |
|
no-cache |
false |
Build without cache. Use ${{ gitea.event_name == 'schedule' }} so weekly rebuilds pick up new packages. Uncached builds are also tagged YYYYMMDD (UTC), which keeps each week's image as a rollback point. |
severity |
CRITICAL,HIGH |
Severities that fail the build. Vulnerabilities without a fixed version never fail it. |
runs-on |
linux-amd64 |
Runner label. |
The image version from the tag/branch (e.g. 1.4.0, main) is passed as
build arg VERSION; declare ARG VERSION in the Dockerfile to use it.
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).
Failure notifications
If variable NTFY_URL is set (full topic URL, e.g.
https://ntfy.hin-fort.ch/ci), a failed build posts to ntfy: Trivy findings
with their CVE IDs, any other failure with a pointer to the log. Both name the
branch and link to the run. Set secret NTFY_TOKEN if the topic needs an
access token. Set both on the user or organisation to cover all its repos.
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
Changing this workflow
Repos reference @main, so a push here reaches all of them on their next
build. Check a change with one run (e.g. a manual run of a small repo) before
moving on, and avoid pushing untested changes before the Friday rebuild. To
undo, revert the commit; every repo picks up the revert the same way.
Upgrading Trivy: change TRIVY_IMAGE in docker-build.yml and the image of
the Gitea-Trivy container to the same version.