From 12534d3afddea229aa4f39bc416b1d6a56edb49a Mon Sep 17 00:00:00 2001 From: Job79 Date: Sun, 8 Nov 2026 11:31:21 +0100 Subject: [PATCH] ci: simplify container build workflow - Drop the changes job; the on.paths filter already does this. - Build all images in one job with buildah, so dependent images use the freshly built local base instead of pulling it. - Only push outside of pull requests; PR builds use a pr- tag. - Reference the base image by its full registry path. Co-Authored-By: Claude Opus 5.5 --- .gitea/workflows/build.yaml | 109 ++++++++------------------------- containers/go/Containerfile | 4 +- containers/infra/Containerfile | 4 +- 3 files changed, 28 insertions(+), 89 deletions(-) diff --git a/.gitea/workflows/build.yaml b/.gitea/workflows/build.yaml index 65ef106..c13ba94 100644 --- a/.gitea/workflows/build.yaml +++ b/.gitea/workflows/build.yaml @@ -10,96 +10,35 @@ on: schedule: - cron: "0 16 * * FRI" +env: + REGISTRY: git.plabble.org + # Images in build order; later images build FROM the local base image. + IMAGES: base go infra + TAG: ${{ github.event_name == 'pull_request' && format('pr-{0}', github.event.number) || github.ref_name }} + PUSH: ${{ github.event_name != 'pull_request' }} + jobs: - changes: - runs-on: job-v2 - outputs: - any_container_change: ${{ steps.filter.outputs.containers == 'true' || steps.filter.outputs.workflow == 'true' || github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' }} - steps: - - uses: actions/checkout@v6 - with: - fetch-depth: 0 - - uses: https://github.com/dorny/paths-filter@v3 - id: filter - with: - filters: | - workflow: ['.gitea/workflows/build.yaml'] - containers: ['containers/**'] - - base-image: - needs: [changes] - if: ${{ needs.changes.outputs.any_container_change == 'true' }} + build: runs-on: job-v2 steps: - uses: actions/checkout@v6 - - name: Log in - uses: redhat-actions/podman-login@v1 - with: - registry: git.plabble.org - username: ${{ secrets.REGISTRY_USERNAME }} - password: ${{ secrets.REGISTRY_TOKEN }} - - name: Build - id: build - uses: job79/buildah-build@65b3793a1370c1ccd74a5c0d090d70eb9637a4ef - with: - image: job79/base - tags: ${{ github.ref_name }} - context: ./containers/base - containerfiles: ./containers/base/Containerfile - platforms: linux/amd64 + run: | + for image in $IMAGES; do + pull=missing; [[ $image == base ]] && pull=newer + buildah build --pull="$pull" --platform linux/amd64 \ + --build-arg TAG="$TAG" \ + -t "$REGISTRY/job79/$image:$TAG" "containers/$image" + done - name: Push - uses: redhat-actions/push-to-registry@v2 - with: - image: ${{ steps.build.outputs.image }} - tags: ${{ steps.build.outputs.tags }} - registry: git.plabble.org - username: ${{ secrets.REGISTRY_USERNAME }} - password: ${{ secrets.REGISTRY_TOKEN }} - extra-args: | - --compression-format=zstd - --compression-level=12 - - dependent-images: - needs: [changes, base-image] - if: ${{ needs.changes.outputs.any_container_change == 'true' }} - runs-on: job-v2 - strategy: - fail-fast: false - matrix: - container: [infra, go] - steps: - - name: Clone repo - uses: actions/checkout@v6 - - - name: Log in - uses: redhat-actions/podman-login@v1 - with: - registry: git.plabble.org - username: ${{ secrets.REGISTRY_USERNAME }} - password: ${{ secrets.REGISTRY_TOKEN }} - - - name: Build - id: build - uses: job79/buildah-build@65b3793a1370c1ccd74a5c0d090d70eb9637a4ef - with: - image: job79/${{ matrix.container }} - tags: ${{ github.ref_name }} - context: ./containers/${{ matrix.container }} - containerfiles: ./containers/${{ matrix.container }}/Containerfile - build-args: TAG=${{ github.ref_name }} - platforms: linux/amd64 - - - name: Push - uses: redhat-actions/push-to-registry@v2 - with: - image: ${{ steps.build.outputs.image }} - tags: ${{ steps.build.outputs.tags }} - registry: git.plabble.org - username: ${{ secrets.REGISTRY_USERNAME }} - password: ${{ secrets.REGISTRY_TOKEN }} - extra-args: | - --compression-format=zstd - --compression-level=12 + if: env.PUSH == 'true' + env: + REGISTRY_USERNAME: ${{ secrets.REGISTRY_USERNAME }} + REGISTRY_TOKEN: ${{ secrets.REGISTRY_TOKEN }} + run: | + buildah login -u "$REGISTRY_USERNAME" --password-stdin "$REGISTRY" <<<"$REGISTRY_TOKEN" + for image in $IMAGES; do + buildah push --compression-format=zstd --compression-level=12 "$REGISTRY/job79/$image:$TAG" + done diff --git a/containers/go/Containerfile b/containers/go/Containerfile index fbf4e87..52fe73a 100644 --- a/containers/go/Containerfile +++ b/containers/go/Containerfile @@ -1,5 +1,5 @@ -ARG TAG -FROM job79/base:${TAG} +ARG TAG=main +FROM git.plabble.org/job79/base:${TAG} USER root RUN set -o pipefail && \ diff --git a/containers/infra/Containerfile b/containers/infra/Containerfile index c6ba026..bee5ea1 100644 --- a/containers/infra/Containerfile +++ b/containers/infra/Containerfile @@ -1,2 +1,2 @@ -ARG TAG -FROM job79/base:${TAG} +ARG TAG=main +FROM git.plabble.org/job79/base:${TAG}