build image with shared traberph/ci workflow
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
+11
-36
@@ -7,42 +7,17 @@ on:
|
|||||||
pull_request:
|
pull_request:
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
|
|
||||||
env:
|
|
||||||
REGISTRY: registry.traberph.de
|
|
||||||
IMAGE: registry.traberph.de/public/interval_viz
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
# Tags and build steps are shared across repos, see traberph/ci.
|
||||||
runs-on: ubuntu-latest
|
image:
|
||||||
steps:
|
uses: traberph/ci/.gitea/workflows/image.yaml@main
|
||||||
- uses: actions/checkout@v4
|
|
||||||
|
|
||||||
- uses: docker/setup-buildx-action@v3
|
|
||||||
|
|
||||||
- name: Log in to registry
|
|
||||||
if: github.event_name != 'pull_request'
|
|
||||||
uses: docker/login-action@v3
|
|
||||||
with:
|
with:
|
||||||
registry: ${{ env.REGISTRY }}
|
project: public
|
||||||
username: ${{ secrets.REGISTRY_USERNAME }}
|
image: interval_viz
|
||||||
password: ${{ secrets.REGISTRY_TOKEN }}
|
|
||||||
|
|
||||||
- name: Image tags
|
|
||||||
id: meta
|
|
||||||
uses: docker/metadata-action@v5
|
|
||||||
with:
|
|
||||||
images: ${{ env.IMAGE }}
|
|
||||||
# main-<sha>-<unix time> sorts by build time, for Flux image automation
|
|
||||||
tags: |
|
|
||||||
type=raw,value=latest,enable={{is_default_branch}}
|
|
||||||
type=raw,value=main-{{sha}}-{{date 'X'}},enable={{is_default_branch}}
|
|
||||||
type=semver,pattern={{version}}
|
|
||||||
type=semver,pattern={{major}}.{{minor}}
|
|
||||||
|
|
||||||
- name: Build and push
|
|
||||||
uses: docker/build-push-action@v6
|
|
||||||
with:
|
|
||||||
context: .
|
|
||||||
push: ${{ github.event_name != 'pull_request' }}
|
push: ${{ github.event_name != 'pull_request' }}
|
||||||
tags: ${{ steps.meta.outputs.tags }}
|
secrets:
|
||||||
labels: ${{ steps.meta.outputs.labels }}
|
registry-username: ${{ secrets.REGISTRY_USERNAME }}
|
||||||
|
registry-token: ${{ secrets.REGISTRY_TOKEN }}
|
||||||
|
# Public image; also pushed to Docker Hub once these secrets exist.
|
||||||
|
dockerhub-username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||||
|
dockerhub-token: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||||
|
|||||||
@@ -92,19 +92,22 @@ credentials are set in `docker-compose.yml`. The host port can be changed with
|
|||||||
|
|
||||||
## CI: build and push
|
## CI: build and push
|
||||||
|
|
||||||
`.gitea/workflows/docker.yml` builds the image with Gitea Actions and pushes it
|
`.gitea/workflows/docker.yml` builds the image (`linux/amd64`, `linux/arm64`) with the
|
||||||
|
shared [`traberph/ci`](https://git.traberph.de/traberph/ci) image workflow and pushes it
|
||||||
to the Harbor registry as `registry.traberph.de/public/interval_viz`.
|
to the Harbor registry as `registry.traberph.de/public/interval_viz`.
|
||||||
|
|
||||||
| Trigger | Tags pushed |
|
| Trigger | Tags pushed |
|
||||||
|--------------------|------------------------------------------------------|
|
|--------------------|------------------------------------------------------|
|
||||||
| push to `main` | `latest`, `main-<sha>-<unix time>` (e.g. `main-6cecbcf-1790415657`) |
|
| push to `main` | `latest`, `<UTC yyyymmddHHMMSS>-<sha7>` (e.g. `20261016171500-6cecbcf`) |
|
||||||
| tag `v1.2.3` | `1.2.3`, `1.2` |
|
| tag `v1.2.3` | `1.2.3`, `1.2`, `1`, `<UTC yyyymmddHHMMSS>-<sha7>` |
|
||||||
| pull request | build only, nothing pushed |
|
| pull request | build only, nothing pushed |
|
||||||
| manual dispatch | as for the selected ref |
|
| manual dispatch | as for the selected ref |
|
||||||
|
|
||||||
The `main-…` tags sort by build time via the trailing timestamp. Flux image
|
The timestamp tags sort by build time. Flux image automation picks the newest one with
|
||||||
automation can pick the newest one with this filter:
|
this filter: `pattern: '^(?P<ts>[0-9]{14})-[a-f0-9]{7}$'`, `extract: '$ts'`, `numerical: asc`.
|
||||||
`pattern: '^main-[a-f0-9]+-(?P<ts>[0-9]+)$'`, `extract: '$ts'`, `numerical: asc`.
|
|
||||||
|
With the `DOCKERHUB_USERNAME` and `DOCKERHUB_TOKEN` secrets set, the same tags are also
|
||||||
|
pushed to `docker.io/<DOCKERHUB_USERNAME>/interval_viz`.
|
||||||
|
|
||||||
Old tags are cleaned up by a tag retention policy in Harbor, not by this workflow.
|
Old tags are cleaned up by a tag retention policy in Harbor, not by this workflow.
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user