update readme

This commit is contained in:
2026-10-18 17:00:16 +02:00
parent 2da87f1c78
commit 192cc26ca1
+86 -30
View File
@@ -4,41 +4,47 @@ Reusable Gitea Actions workflows for the apps in the cluster. Needs Gitea 1.27 o
expands called workflows on the server into their own jobs. The repository is public so every expands called workflows on the server into their own jobs. The repository is public so every
repo can call it. repo can call it.
## `image.yaml` ## Usage
Builds and pushes one image with a uniform tag set from Add a workflow with the same name as the shared one, `.gitea/workflows/image.yaml`, to the
[docker/metadata-action](https://github.com/docker/metadata-action): calling repo and set `project` and `image`:
| Tag | When |
|---|---|
| `<UTC yyyymmddHHMMSS>-<sha7>` | every build; the timestamp is the **commit** time, Flux `ImagePolicy` sorts on it |
| `1.2.3`, `1.2`, `1` | on a `v1.2.3` git tag (`1` is skipped while the major is `0`; pre-releases only get the full version) |
| `latest` | on the default branch |
The tags depend only on the commit, not on when it was built. A repo with several images calls
the workflow once per image (the calls run as separate jobs, in parallel) and every image gets the
same tags; rebuilding a commit re-pushes its tags instead of producing a newer one.
If the `dockerhub-username` and `dockerhub-token` secrets are passed, every image is also pushed with the same tags to `docker.io/<dockerhub-username>/<image>`, e.g. `registry.traberph.de/public/homepage` → `docker.io/traberph/homepage`. Only pass them for public images: Docker Hub creates new repositories as public by default.
```yaml ```yaml
name: Build image
on:
push:
branches: [main]
tags: ["v*"]
paths-ignore: ["**.md"]
pull_request:
workflow_dispatch:
jobs: jobs:
test: ... # Tags and build steps are shared across repos, see traberph/ci.
image: image:
needs: test
uses: traberph/ci/.gitea/workflows/image.yaml@v1.0.0 uses: traberph/ci/.gitea/workflows/image.yaml@v1.0.0
with: with:
project: public project: public
image: homepage image: interval-viz
push: ${{ github.event_name != 'pull_request' }} push: ${{ github.event_name != 'pull_request' }}
secrets: secrets:
registry-username: ${{ secrets.REGISTRY_USERNAME }} registry-username: ${{ secrets.REGISTRY_USERNAME }}
registry-token: ${{ secrets.REGISTRY_TOKEN }} registry-token: ${{ secrets.REGISTRY_TOKEN }}
dockerhub-username: ${{ secrets.DOCKERHUB_USERNAME }} # optional
dockerhub-token: ${{ secrets.DOCKERHUB_TOKEN }} # optional
``` ```
Inputs: This builds `registry.traberph.de/public/interval-viz` on every push, pull request and manual
run, and pushes it except for pull requests. The repo needs the `REGISTRY_USERNAME` and
`REGISTRY_TOKEN` secrets (a Harbor robot account with push access to the project).
To run tests first, add a `test` job and set `needs: test` on `image`.
## `image.yaml`
Builds and pushes one image with a uniform tag set from
[docker/metadata-action](https://github.com/docker/metadata-action).
### Inputs
- `registry`: default `registry.traberph.de`. - `registry`: default `registry.traberph.de`.
- `project` (required): Harbor project, e.g. `public` or `private`. - `project` (required): Harbor project, e.g. `public` or `private`.
@@ -47,12 +53,52 @@ Inputs:
- `dockerfile`: default `<context>/Dockerfile`. - `dockerfile`: default `<context>/Dockerfile`.
- `platforms`: default `linux/amd64,linux/arm64`. QEMU is set up when an `arm` platform is listed. - `platforms`: default `linux/amd64,linux/arm64`. QEMU is set up when an `arm` platform is listed.
- `build-args`: newline-separated `KEY=value`. - `build-args`: newline-separated `KEY=value`.
- `push`: default `true`. - `push`: `"true"` (default) or `"false"`.
- `cache`: keep the layer cache in Harbor as `<image>:buildcache` (default `false`). - `cache`: `"true"` keeps the layer cache in Harbor as `<image>:buildcache` (default `"false"`).
Outputs: `tag` (the timestamp tag), `version`, `tags` (the full image references). `push` and `cache` are strings, not booleans: on Gitea 1.27 with gitea/runner v2.0.1 every boolean
input of a called workflow arrives as `false`. An expression like
`${{ github.event_name != 'pull_request' }}` works as is.
Several images: one job per image, e.g. ### Secrets
- `registry-username`, `registry-token`: login for `registry`, only needed when pushing.
- `dockerhub-username`, `dockerhub-token` (optional): see [Docker Hub](#docker-hub).
### Outputs
`tag` (the timestamp tag), `version`, `tags` (the full image references).
### Tags
| Tag | When |
|---|---|
| `<UTC yyyymmddHHMMSS>-<sha7>` | every build; the timestamp is the **commit** time, Flux `ImagePolicy` sorts on it |
| `1.2.3`, `1.2`, `1` | on a `v1.2.3` git tag (`1` is skipped while the major is `0`; pre-releases only get the full version) |
| `latest` | on the default branch |
The tags depend only on the commit, not on when it was built: rebuilding a commit re-pushes its
tags instead of producing a newer one.
### Docker Hub
If `dockerhub-username` and `dockerhub-token` are passed, the image is also pushed with the same
tags to `docker.io/<dockerhub-username>/<image>`, e.g. `registry.traberph.de/public/homepage` →
`docker.io/traberph/homepage`. Only pass them for public images: Docker Hub creates new
repositories as public by default.
```yaml
secrets:
registry-username: ${{ secrets.REGISTRY_USERNAME }}
registry-token: ${{ secrets.REGISTRY_TOKEN }}
dockerhub-username: ${{ secrets.DOCKERHUB_USERNAME }}
dockerhub-token: ${{ secrets.DOCKERHUB_TOKEN }}
```
### Several images
Call the workflow once per image. The calls run as separate jobs in parallel, and every image of
a commit gets the same tags:
```yaml ```yaml
jobs: jobs:
@@ -69,19 +115,29 @@ jobs:
A matrix over images inside the called workflow (`matrix: ${{ fromJSON(inputs.…) }}`) does not A matrix over images inside the called workflow (`matrix: ${{ fromJSON(inputs.…) }}`) does not
work on Gitea 1.27.0: its parser panics while expanding the call and the run is never created. work on Gitea 1.27.0: its parser panics while expanding the call and the run is never created.
## Versions ## Versions and Renovate
Callers pin a release tag (`@v1.0.0`). Renovate in the calling repos proposes new tags; it needs Callers pin a release tag (`@v1.0.0`). The self-hosted Renovate in the cluster (see
a rule pointing `traberph/ci` at this Gitea: `cumulus/apps/base/renovate`) monitors the calling repos itself, so they need no Renovate
workflow, only a `renovate.json`. Renovate looks up `traberph/ci` on github.com by default, so the
config has to point it at this Gitea:
```json ```json
{ {
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
"extends": ["config:recommended"],
"timezone": "Europe/Berlin",
"packageRules": [
{
"description": "The shared image workflow lives on this Gitea, not on github.com",
"matchDepNames": ["traberph/ci"], "matchDepNames": ["traberph/ci"],
"overrideDatasource": "gitea-tags", "overrideDatasource": "gitea-tags",
"registryUrls": ["https://git.traberph.de"] "registryUrls": ["https://git.traberph.de"]
}
]
} }
``` ```
## Updates Renovate then opens a PR in the calling repo for each new release tag of this repo.
Renovate (running in the cluster, see `cumulus/apps/base/renovate`) opens PRs for the actions used here; see [`renovate.json`](renovate.json). The actions used in this repo are kept up to date the same way; see [`renovate.json`](renovate.json).