diff --git a/.gitea/workflows/docker.yml b/.gitea/workflows/docker.yml index d0c3f5d..53d6f82 100644 --- a/.gitea/workflows/docker.yml +++ b/.gitea/workflows/docker.yml @@ -7,42 +7,17 @@ on: pull_request: workflow_dispatch: -env: - REGISTRY: registry.traberph.de - IMAGE: registry.traberph.de/public/interval_viz - jobs: - build: - runs-on: ubuntu-latest - steps: - - 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: - registry: ${{ env.REGISTRY }} - username: ${{ secrets.REGISTRY_USERNAME }} - password: ${{ secrets.REGISTRY_TOKEN }} - - - name: Image tags - id: meta - uses: docker/metadata-action@v5 - with: - images: ${{ env.IMAGE }} - # main-- 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' }} - tags: ${{ steps.meta.outputs.tags }} - labels: ${{ steps.meta.outputs.labels }} + # Tags and build steps are shared across repos, see traberph/ci. + image: + uses: traberph/ci/.gitea/workflows/image.yaml@main + with: + project: public + image: interval_viz + push: ${{ github.event_name != 'pull_request' }} + secrets: + 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 }} diff --git a/README.md b/README.md index 3860666..b032e89 100644 --- a/README.md +++ b/README.md @@ -92,19 +92,22 @@ credentials are set in `docker-compose.yml`. The host port can be changed with ## 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`. | Trigger | Tags pushed | |--------------------|------------------------------------------------------| -| push to `main` | `latest`, `main--` (e.g. `main-6cecbcf-1790415657`) | -| tag `v1.2.3` | `1.2.3`, `1.2` | +| push to `main` | `latest`, `-` (e.g. `20261016171500-6cecbcf`) | +| tag `v1.2.3` | `1.2.3`, `1.2`, `1`, `-` | | pull request | build only, nothing pushed | | manual dispatch | as for the selected ref | -The `main-…` tags sort by build time via the trailing timestamp. Flux image -automation can pick the newest one with this filter: -`pattern: '^main-[a-f0-9]+-(?P[0-9]+)$'`, `extract: '$ts'`, `numerical: asc`. +The timestamp tags sort by build time. Flux image automation picks the newest one with +this filter: `pattern: '^(?P[0-9]{14})-[a-f0-9]{7}$'`, `extract: '$ts'`, `numerical: asc`. + +With the `DOCKERHUB_USERNAME` and `DOCKERHUB_TOKEN` secrets set, the same tags are also +pushed to `docker.io//interval_viz`. Old tags are cleaned up by a tag retention policy in Harbor, not by this workflow.